jono261970
Programmer
Hi,
I have an access table with location,make,model and qty fields. I want to display contents of location into combo and display the other fields in text boxes depending on which location has been selected in combo.
I got hold of the following code but can`t make it work?
===================================================
Combo0.RowSource = "Select Table1.Location from Table1;"
Private Sub Combo0_AfterUpdate()
Sql= "SELECT Table1.Location, Table1.Make, Tablel1.Model, Table1.Qty " & _ "FROM Table1 " & _
"WHERE (((Table1.Location)='" & Combo0.Text & "'));"
Set myDB = CurrentDb
Set myRS = myDB.OpenRecordset(Sql, dbOpenDynaset)
If Not (myRS.EOF And myRS.BOF) Then
Text1 = myRS.Fields("Make"
Text2 = myRS.Fields("Model"
Text3 = myRS.Fields("Qty"
End If
End Sub
=====================================================
I have tried changing currentdb to c:\printDB.mdb but to no avail.
I`m really struggling here, I would really appreciate it if somebody could spare 5 mins to guide me through this.
kind regards,
jono
I have an access table with location,make,model and qty fields. I want to display contents of location into combo and display the other fields in text boxes depending on which location has been selected in combo.
I got hold of the following code but can`t make it work?
===================================================
Combo0.RowSource = "Select Table1.Location from Table1;"
Private Sub Combo0_AfterUpdate()
Sql= "SELECT Table1.Location, Table1.Make, Tablel1.Model, Table1.Qty " & _ "FROM Table1 " & _
"WHERE (((Table1.Location)='" & Combo0.Text & "'));"
Set myDB = CurrentDb
Set myRS = myDB.OpenRecordset(Sql, dbOpenDynaset)
If Not (myRS.EOF And myRS.BOF) Then
Text1 = myRS.Fields("Make"
Text2 = myRS.Fields("Model"
Text3 = myRS.Fields("Qty"
End If
End Sub
=====================================================
I have tried changing currentdb to c:\printDB.mdb but to no avail.
I`m really struggling here, I would really appreciate it if somebody could spare 5 mins to guide me through this.
kind regards,
jono