|
-
Dec 27th, 2008, 04:50 AM
#1
Thread Starter
Lively Member
[RESOLVED] Connecting Access to Combobox to List box to text box
Hi Everyone, I hope to get help here. I dont know much about programming. I am doing my final project regarding to structural Design - specifically Truss design using Eurocode 3. I were asked to make a program for the calculation using VB6 by my Lecturer.
First I want to create a program contain combo box which shows the type of table. from the combo box, user can choose the type of table from the access database and then one of the field (e.g Size of truss) from the table appeared in the list box - the list of all the truss sizes. then, user may choose the size of truss he want. after choosing one size from the list, the properties of the chosen size of truss will all in the text boxes such as txtHeight, txtwidth, txtarea and ect.
this is my attempt to get the database using ADO. I manage to let the combobox to drop down with the table NAME but fail get the Sizes of truss to be listed in the list box...
Code:
Private Cn As ADODB.Connection
Private rstSchema As ADODB.Recordset
Private strCn As String
Private Sub OpenDB()
Set Cn = New ADODB.Connection
strCn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\ub2.mdb;" & _
"Persist Security Info=False"
Cn.Open strCn
End Sub
Private Sub Form_load()
OpenDB
Set rstSchema = Cn.OpenSchema(adSchemaTables)
Do Until rstSchema.EOF
If UCase(rstSchema.Fields("TABLE_TYPE").Value & "") = "TABLE" Then
Combo1.AddItem " " & rstSchema.Fields("TABLE_NAME").Value
End If
rstSchema.MoveNext
Loop
rstSchema.Close
Set rstSchema = Nothing
OpenDB
Set rstSchema = Cn.OpenSchema(adSchemaColumns)
Do Until rstSchema.EOF
If UCase(rstSchema.Fields("TABLE_Name").Value & "") = Combo1.Text Then
List1.AddItem " " & rstSchema.Fields("COLUMN_NAME").Value
End If
rstSchema.MoveNext
Loop
rstSchema.Close
Set rstSchema = Nothing
End Sub
I got this code from other forum
http://www.vbforums.com/showthread.php?t=452910
The program just run as usual but when I had choose the table from the combobox (List box), nothing happened to the listbox (List1). I got stuck here and I couldn't continue with the textbox.
Please help...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|