susieqtotallynew
MIS
Hi, all,
In my access database, I am using a form to allow users to enter parameters for ID, Constituency Type and Class Year. The command button on the form runs the following VB code:
Private Sub RunQuery_Click()
Dim db As DAO.Database
Dim QD As QueryDef
Dim where As Variant
Set db = CurrentDb()
On Error Resume Next
db.QueryDefs.Delete ("Dynamic_Query")
On Error GoTo 0
where = Null
where = where & " AND [ID]='" + Me![id] + "'"
where = where & " AND [ConstituencyType]='" + Me![ConstituencyType] + "'"
where = where & " AND [ClassYear]='" + Me![ClassYear]
DoCmd.OpenQuery "Dynamic_Query"
End Sub
However, when I click the button an error, 7874 appears, telling me that Access can't find the Object 'Dynamic_Query'. What am I doing wrong?
Thanks for your help in advance...I am new to this.
In my access database, I am using a form to allow users to enter parameters for ID, Constituency Type and Class Year. The command button on the form runs the following VB code:
Private Sub RunQuery_Click()
Dim db As DAO.Database
Dim QD As QueryDef
Dim where As Variant
Set db = CurrentDb()
On Error Resume Next
db.QueryDefs.Delete ("Dynamic_Query")
On Error GoTo 0
where = Null
where = where & " AND [ID]='" + Me![id] + "'"
where = where & " AND [ConstituencyType]='" + Me![ConstituencyType] + "'"
where = where & " AND [ClassYear]='" + Me![ClassYear]
DoCmd.OpenQuery "Dynamic_Query"
End Sub
However, when I click the button an error, 7874 appears, telling me that Access can't find the Object 'Dynamic_Query'. What am I doing wrong?
Thanks for your help in advance...I am new to this.