Associate
- Joined
- 25 Oct 2007
- Posts
- 342
- Location
- Southampton
Hello,
I'm currently doing an extended project in computing, which is related to acoustics etc, and this consists of a program and a database linked together. Ideally, what I would like to happen is that there are two list boxes populated from the database. The user selects something from a combobox which then updates a listbox accordingly - then the user selects from that list box, which updates the second one. Then, when the user selects something from the second list box, I want a text box to be updated automatically with a field from that piece of data.
For example, the user selects "Ceiling" in the combo box, the first list box updates with a list of ceiling materials. The user then selects "Acoustic Tile", which updates the second list box with special properties. The program works up until here. Now, say the user selected "Suspended" from the second list box - I would then want the program to query the database for the field "Mat_Absorb_1000" of Suspended Acoustic Tile, where Acoustic Tile comes under "Material_Name", and Suspended comes under "Material_Special".
At the moment, when the user selects suspended, I get the error "No current record", and when I inserted a message box to tell me the number of fields in the recordset, it returned 0 - Now my SQL query works in Access, so I'm wondering what could be the problem? Here's the relevant code:
Sorry for the lengthy post, but if anyone could offer an insight it'd be much appreciated - my computing teacher was stumped 
I'm currently doing an extended project in computing, which is related to acoustics etc, and this consists of a program and a database linked together. Ideally, what I would like to happen is that there are two list boxes populated from the database. The user selects something from a combobox which then updates a listbox accordingly - then the user selects from that list box, which updates the second one. Then, when the user selects something from the second list box, I want a text box to be updated automatically with a field from that piece of data.
For example, the user selects "Ceiling" in the combo box, the first list box updates with a list of ceiling materials. The user then selects "Acoustic Tile", which updates the second list box with special properties. The program works up until here. Now, say the user selected "Suspended" from the second list box - I would then want the program to query the database for the field "Mat_Absorb_1000" of Suspended Acoustic Tile, where Acoustic Tile comes under "Material_Name", and Suspended comes under "Material_Special".
At the moment, when the user selects suspended, I get the error "No current record", and when I inserted a message box to tell me the number of fields in the recordset, it returned 0 - Now my SQL query works in Access, so I'm wondering what could be the problem? Here's the relevant code:
Code:
Option Explicit
Dim materials As Database
Dim rs As Recordset
Dim rs_lstsurfacemat As Recordset
Dim rs_lstsurfaceadj As Recordset
Dim rs_txtsurfacecoef As Recordset
Code:
Private Sub lst_surfaceadj_Click()
Set rs_txtsurfacecoef = materials.OpenRecordset("select Materials.Mat_Absorb_1000 from Materials where ((Materials.Material_Name = ' " & lst_surfacemat.Text & " ') AND (Material_Special = ' " & lst_surfaceadj.Text & " '))")
MsgBox rs_txtsurfacecoef.RecordCount
lbl_surfacecoef.Caption = rs_txtsurfacecoef![Mat_Absorb_1000]
End Sub
