I want to write a very simple query and bind it to a listbox with VBA code but an error occures by running this piece of code:
Private Sub Command0_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM funk", dbOpenTable)
Me.List9.Recordset = rs
End Sub
the name of the databse is correct. Could you please inform me how can I solve this problem?
Edit
I’ve changed my code to
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM funk")
Me.List9.Recordset = rs
but it doesn’t work too
There is no need for such complication:
However, it would be much better to say:
You can the hide the ID field yet any selection in a simple select is equal to the ID when the Bound Column is 1.
You will need:
Note Set on the last line.