Query for data base
I have a simple database set up and I am trying to use a simple SQL statement to query the data base but keep getting errors. This is what I have:
Private Sub cmdQuery_Click(Index As Integer)
datDataBase.RecordSource = "Select * from [Car Insurance Form]"
datDataBase.Refresh
End Sub
Car Insurance Form is the name of the data base. keeps brining up a 'run time error 424' object required. What do I do?
[451 byte] By [
coloughl] at [2007-11-15 18:34:40]

# 1 Re: Query for data base
Does your program know what datDataBase is?
You need to ensure that you call the database by name and open it first. This may be why you are getting object required.
Microsoft Help files usually refer to the data control.
Thus
Dim Db As Database, Rs As Recordset ' Defined as public variables.
Sub ApplyRecordset()
Set Db = Workspaces(0).OpenDatabase("BIBLIO.MDB")
Set Rs = Db.OpenRecordset("AUTHORS") ' Defaults to Table object.
Set Data1.Recordset = Rs ' Assign Recordset.
Data1.Recordset.Index = "PrimaryKey"
Debug.print Rs.Type ' Show type created.
End Sub
Andyb at 2007-11-10 0:33:48 >
