Link to home
Start Free TrialLog in
Avatar of DAVIDH
DAVIDH

asked on

DB GRID CONTROL AND DATA ACCESS

This is really annonying me.  I have an access DB that I am accessing through VB.  I have a DBcombo DBGrid and Data Control.

I have about 7 forms.  Main form calls the other forms where I am running a query.  On the first 3 forms this works fine:

Private Sub DBCombo1_Click(Area As Integer)

Let Me.Data1.RecordSource = "SELECT * FROM [STUDENT QUERY] WHERE [student id]= '" & _
Me!DBCombo1.Text & "'"
Me.Data1.Refresh


Even though It appears that I have the exact same code and properties for the controls, On all the other forms when I open the dbcombo or when the form loads, I get this message

Runtime Error 438
Object does not support this property or method
It occurs with the Data1.Refresh.

If I remove Data1.refresh I don't get errors, but of course the dbgrid is not bound to my dbcombo.

What am I doing wrong?
thanks
ASKER CERTIFIED SOLUTION
Avatar of anthonyc
anthonyc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DAVIDH
DAVIDH

ASKER

It does not give me an error message, but it does not update anything either.

Any other ideas?
I would try this:

dim rs as recordset

set rs = data1.database.openrecordset("select * from table1", dbOpenDynaset)
set data1.recordset = rs
dbgrid1.rebind


Avatar of DAVIDH

ASKER

I found the problem,  Each form has a Data1 on it, When I change the name to data6 and the dbgrid recordsource to data6 it works, go figure, it must have been looking at a datacontrol on another form.

David