Hey,
Right, after googling a lot last week and trwsling through the first few pages of Dlookup search results here, i'm at a copmplete loss....
I'm building a school reports database. To avoid having empty boxes for options (the kids choose 2 or 3 out of a possible 7 or 8) i'm doing some code to extract their options and build a custom query on the fly when a button is clicked.
I got it all working fine using DLookups, but then to pretty the whole thing up and make it usable I put the form in a navigation form as a subform.....and now the code breaks
To try and cut down on the chance of the erro being in a different line and access just highlighting the DLookup line, i've commented out nearly everything, leaving me with the following:
I've cut out a whole bunch of commented out stuff to save space.
WHen I try and run it, it highlights the DLookup line, with the error "Runtime Error: 2450 Microsoft Access cannot find the reference form 'argh'"
argh is the name of the form that has the button this code runs from. Thing is, I can't see where the form is referenced
Any help much appreciated!
Thanks
Right, after googling a lot last week and trwsling through the first few pages of Dlookup search results here, i'm at a copmplete loss....
I'm building a school reports database. To avoid having empty boxes for options (the kids choose 2 or 3 out of a possible 7 or 8) i'm doing some code to extract their options and build a custom query on the fly when a button is clicked.
I got it all working fine using DLookups, but then to pretty the whole thing up and make it usable I put the form in a navigation form as a subform.....and now the code breaks

To try and cut down on the chance of the erro being in a different line and access just highlighting the DLookup line, i've commented out nearly everything, leaving me with the following:
Code:
Public Sub Command0_Click()
'This creates a database object, then 2 query objects
Dim db As DAO.Database
Dim qdf As QueryDef
Dim Report_Data As QueryDef
'This sets the db object as the current database, then the 2 query objects to the query we're creating
'and the query holding the data we want
Set db = CurrentDb
Set qdf = db.QueryDefs("qryStudRepData")
Set Report_Data = db.QueryDefs("qryReport")
'Variables, wooo!
Dim Option1 As String
Dim Option2 As String
Dim Option3 As String
Dim Option1SQL As String
Dim Option2SQL As String
Dim Option3SQL As String
Dim Option1Query As String
Dim Option2Query As String
Dim Option3Query As String
Dim Student As String
Dim strSQL As String
Dim strMessage As String
'Sets the Student variable to equal the value of a combo box on the form - however, as it's now a subform we have to do the full path to the control
Student = Forms![Navigation Form]![NavigationSubform].Form!cboStudent
Option1 = DLookup("RegGrp", "qryReport", "Student_Name='Andrew Craig Saxon'")
MsgBox (Option1)
End Sub
I've cut out a whole bunch of commented out stuff to save space.
WHen I try and run it, it highlights the DLookup line, with the error "Runtime Error: 2450 Microsoft Access cannot find the reference form 'argh'"
argh is the name of the form that has the button this code runs from. Thing is, I can't see where the form is referenced

Any help much appreciated!
Thanks
