SQL Statement - Requery

Mechele

Registered User.
Local time
Today, 15:30
Joined
Jan 25, 2002
Messages
121
Private Sub NameofCompany_AfterUpdate()
Dim StrSQL As String
Dim QDF As QueryDef
Dim CurrentDB As Database

StrSQL = "SELECT * FROM GeneralInformationTable;"
Me.List1.RowSource = StrSQL
Me.List1.Requery

Set QDF = CurrentDB.QueryDefs(TempQuery)
QDF.SQL = StrSQL
QDF.Close
End Sub

The above code is giving me an error message:

Run Time 91

Object variable or with block variable not set.

What am I doing wrong? :O(
:mad:
 
No need to declare CurrentDB, try commenting out this line

Code:
Dim CurrentDB As Database
 
CurrentDB is a reserved word in VBA. Also think that it will fall at Set QDF = CurrentDB.QueryDefs(TempQuery). If TempQuery exists then it should be in double quotes ie ...("TempQuery"). If TempQuery does not exist then you will need to create it. Look at the CreateQueryDef in help

HTH
 

Users who are viewing this thread

Back
Top Bottom