|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
|||
|
|||
|
I am 4 days @ 18hour days trying to figure out how to set up a datacombo box up from data on an access database. It took till early this morning to figure out that the drop down box was wrong and the datacombo box is what I need. I have spent all day reading several books, searching several postings but can't figure it out. I saw posting stating it is easy but I can't figure it out at all.
To be specific: I took an access dataset and used the VB6 Application wizard to import the database into VB6. But all it gave me was text boxes. This is great for about 1/2 of the fields but I need 1/2 to be a datalist and datacombo boxes. I have verified the connection to the database was successful. I can even get the datacombo box and datalist box on the form... But thats it. I have had a long day of trying every thing I can think of...... Can any one help an old man figure it out??? The coding for the master table is as follows: *****Begin Code******* Dim WithEvents adoPrimaryRS As Recordset Dim mbChangedByCode As Boolean Dim mvBookMark As Variant Dim mbEditFlag As Boolean Dim mbAddNewFlag As Boolean Dim mbDataChanged As Boolean Private Sub DataCombo1_Click(Area As Integer) End Sub Private Sub Form_Load() Dim db As Connection Set db = New Connection db.CursorLocation = adUseClient db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MCD_Prototype_Demo\Acess97Convert.mdb;" Set adoPrimaryRS = New Recordset adoPrimaryRS.Open "select [Asset No],[CAD System],[CAR No],[Checked By],[Checked Date],Comments,Department,Description,[Devel By],[Devel Date],[File Name],[Manuf Location],Project,[Released By],[Released Date],[Rev By],[Rev Checked By],[Rev Checked Date],[Rev Comments],[Rev Date],[Rev Released By],[Rev Released Date],[Revision Lvl],[Spare 1],[Spare 2],[Spare 3],[Spare 4],[Spare 5],[Upper Level Assembly] from [Master Data Set] Order by [File Name]", db, adOpenStatic, adLockOptimistic Dim oText As TextBox 'Bind the text boxes to the data provider For Each oText In Me.txtFields Set oText.DataSource = adoPrimaryRS Next mbDataChanged = False End Sub Private Sub Form_Resize() On Error Resume Next lblStatus.Width = Me.Width - 1500 cmdNext.Left = lblStatus.Width + 700 cmdLast.Left = cmdNext.Left + 340 End Sub Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If mbEditFlag Or mbAddNewFlag Then Exit Sub Select Case KeyCode Case vbKeyEscape cmdClose_Click Case vbKeyEnd cmdLast_Click Case vbKeyHome cmdFirst_Click Case vbKeyUp, vbKeyPageUp If Shift = vbCtrlMask Then cmdFirst_Click Else cmdPrevious_Click End If Case vbKeyDown, vbKeyPageDown If Shift = vbCtrlMask Then cmdLast_Click Else cmdNext_Click End If End Select End Sub Private Sub Form_Unload(Cancel As Integer) Screen.MousePointer = vbDefault End Sub Private Sub adoPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset) 'This will display the current record position for this recordset lblStatus.Caption = "Record: " & CStr(adoPrimaryRS.AbsolutePosition) End Sub Private Sub adoPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset) 'This is where you put validation code 'This event gets called when the following actions occur Dim bCancel As Boolean Select Case adReason Case adRsnAddNew Case adRsnClose Case adRsnDelete Case adRsnFirstChange Case adRsnMove Case adRsnRequery Case adRsnResynch Case adRsnUndoAddNew Case adRsnUndoDelete Case adRsnUndoUpdate Case adRsnUpdate End Select If bCancel Then adStatus = adStatusCancel End Sub Private Sub cmdAdd_Click() On Error GoTo AddErr With adoPrimaryRS If Not (.BOF And .EOF) Then mvBookMark = .Bookmark End If .AddNew lblStatus.Caption = "Add record" mbAddNewFlag = True SetButtons False End With Exit Sub AddErr: MsgBox Err.Description End Sub Private Sub cmdDelete_Click() On Error GoTo DeleteErr With adoPrimaryRS .Delete .MoveNext If .EOF Then .MoveLast End With Exit Sub DeleteErr: MsgBox Err.Description End Sub Private Sub cmdRefresh_Click() 'This is only needed for multi user apps On Error GoTo RefreshErr adoPrimaryRS.Requery Exit Sub RefreshErr: MsgBox Err.Description End Sub Private Sub cmdEdit_Click() On Error GoTo EditErr lblStatus.Caption = "Edit record" mbEditFlag = True SetButtons False Exit Sub EditErr: MsgBox Err.Description End Sub Private Sub cmdCancel_Click() On Error Resume Next SetButtons True mbEditFlag = False mbAddNewFlag = False adoPrimaryRS.CancelUpdate If mvBookMark > 0 Then adoPrimaryRS.Bookmark = mvBookMark Else adoPrimaryRS.MoveFirst End If mbDataChanged = False End Sub Private Sub cmdUpdate_Click() On Error GoTo UpdateErr adoPrimaryRS.UpdateBatch adAffectAll If mbAddNewFlag Then adoPrimaryRS.MoveLast 'move to the new record End If mbEditFlag = False mbAddNewFlag = False SetButtons True mbDataChanged = False Exit Sub UpdateErr: MsgBox Err.Description End Sub Private Sub cmdClose_Click() Unload Me End Sub Private Sub cmdFirst_Click() On Error GoTo GoFirstError adoPrimaryRS.MoveFirst mbDataChanged = False Exit Sub GoFirstError: MsgBox Err.Description End Sub Private Sub cmdLast_Click() On Error GoTo GoLastError adoPrimaryRS.MoveLast mbDataChanged = False Exit Sub GoLastError: MsgBox Err.Description End Sub Private Sub cmdNext_Click() On Error GoTo GoNextError If Not adoPrimaryRS.EOF Then adoPrimaryRS.MoveNext If adoPrimaryRS.EOF And adoPrimaryRS.RecordCount > 0 Then Beep 'moved off the end so go back adoPrimaryRS.MoveLast End If 'show the current record mbDataChanged = False Exit Sub GoNextError: MsgBox Err.Description End Sub Private Sub cmdPrevious_Click() On Error GoTo GoPrevError If Not adoPrimaryRS.BOF Then adoPrimaryRS.MovePrevious If adoPrimaryRS.BOF And adoPrimaryRS.RecordCount > 0 Then Beep 'moved off the end so go back adoPrimaryRS.MoveFirst End If 'show the current record mbDataChanged = False Exit Sub GoPrevError: MsgBox Err.Description End Sub Private Sub SetButtons(bVal As Boolean) cmdAdd.Visible = bVal cmdEdit.Visible = bVal cmdUpdate.Visible = Not bVal cmdCancel.Visible = Not bVal cmdDelete.Visible = bVal cmdClose.Visible = bVal cmdRefresh.Visible = bVal cmdNext.Enabled = bVal cmdFirst.Enabled = bVal cmdLast.Enabled = bVal cmdPrevious.Enabled = bVal End Sub *************End of Code ****************** |
|
#2
|
|||
|
|||
|
Did you try the code that I supplied you with on your other post?
|
|
#3
|
|||
|
|||
|
victorpendleton, Yes I Did try it and it was unsuccessful. How ever I had played around and it appears I had stumbled my way through and found that my real problem has beed the physical linking of the datacombo feature with the data source. I have read sooooo many postings with soo many different approaches. I had accidently made the connection but unfortunately at this moment I can't reduplicated.
I am now at the 12th hour. And I don't have time to further develop it at this time. 7am tomorrow I need to present a presentation to show if Visual Basic will be the answer to the company document control issues. I will just have to BS my way through it. Right now I am trying to figure out why I keep getting errors when I try an install the pack and install feature; I posted a nother posting for it. The complete story is this. I am 100% green on the VB. I am primarily a CAD Machine designer and my epecialty is 3D Modeling with Solid Works. We have until Dec 31st to comply with FDA. Our Document and drawing control is currently being handled via Excell manually. We need a control to link Access Databas to Solidworks to provide the direct link and security controls. We have evaluated several company's out there but the $100,000.00 tag is a bit much. So I decided to research a solution. I tried all I could for the last 2 weeks. All I can do now is present it in the hopes they will accept it. If they Do they will be sending me to proper schooling to properly learn VB..................... Bummer I couldn't get DataCombo down to a science. But for all that replyied thanks. I was a big help[. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > How do you setup a datacombo box to an access data base? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|