
ADO recordset: Object variable or with block variable not set
Hello,
I am working on this for a few days, did a lot of research but no luck... I
hope someone here can help me.
In VB6(sp5) I have several ADO-controls connected to different tables in a
database (Access 2000). I want to fill regular (not data) comboboxes with
records from some tables. This code works fine:
Private Sub Command3_Click()
AdoProject.Recordset.MoveFirst
Do Until AdoProject.Recordset.EOF
Combo1.AddItem AdoProject.Recordset.Fields("Project").Value
AdoProject.Recordset.MoveNext
Loop
End Sub
<<
But what gets me is that this code doesn't work:
Private Sub Command4_Click()
AdoOpdrachtCodes.Recordset.MoveFirst
Do Until AdoOpdrachtCodes.Recordset.EOF
Combo2.AddItem
AdoOpdrachtCodes.Recordset.Fields("Opdrachtcode").Value
Adoopdrachtcode.Recordset.MoveNext
Loop
End Sub
<<
It doesn't matter which code I run first, the AdoOpdrachtCodes one gives me
the error: Object variable or with block variable not set.
The database has a table "Project" which contains the field "Project" and
there's a table "Opdrachtcodes" which contains the field "Opdrachtcode" and
both tables are filled.
Any help on this would be great!
Thanks in advance,
Mark