ADO recordset: Object variable or with block variable not set 
Author Message
 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



Sat, 12 Nov 2005 01:49:37 GMT  
 ADO recordset: Object variable or with block variable not set
Maybe I found something... The AdoOpdracht has a DataGrid bound to it. When
I change the DataGrids datasource to AdoOpdrachtCodes, the other code
works!! So I could add DataGrids for all tables, but I don't think that's
the way... or is it?


Quote:
> 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



Sat, 12 Nov 2005 01:52:58 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Error msg: Object variable or With block variable not set

2. Object variable or With block variable not set when calling COM Dll

3. Object variable or With block variable not set (Error 91)

4. Object variable or With Block variable not set

5. error 91 Object Variable o on with block variable is not set

6. Object variable or With block variable not set

7. Runtime error 91/Object variable or With block variable not set problems

8. Object variable or With block variable not set

9. Object variable or with block variable not set

10. Object variable or With block variable not set error in Class

11. runtime error: 91 Object variable or with block variable not set

12. Object variable or With block variable not set when using simple class example

 

 
Powered by phpBB® Forum Software