I have a combo box on a form and I want to load some items in this combo box at run time from a database table of access. For this I have written below code. But when I start my program this message appears.
Run-time error '91':
Object variable or With bock variable not set

Code is this:
Private Sub Form_Load()
Dim A As String

Data1.Recordset.MoveFirst
Do While Data1.Recordset.EOF <> True
A = Data1.Recordset.Fields("Religion") & ""
If A <> "" Then
Combo1.AddItem A
End If
Data1.Recordset.MoveNext
Loop
End Sub

Hi,

I think that the Data1 object is not set to database.

If not please set the below property for Data1 Object
Databasename
RecordSource

Thanks
Mahesh

plz check it.

Thanks, I have solved my problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.