Headscratcher - Query using form data/VBA

funderburgh

Registered User.
Local time
Today, 15:54
Joined
Jun 25, 2008
Messages
118
I manage an Access application that in many instances uses data selected from a combo on a form for variable criteria. In this instance it is in the form of:

[Forms]![Main Navigation]![Print Menu]![SchoolYear]

I recently wrote a routing that exports to Excel based on a record set derived from a query. In testing I hard-coded the criteria (School Year) in the query. Once everything worked I sustituted the variable above. Now, in the VBA, no records are put into the recordset, but here is the "HUH?" - when I run the queries directly from Access they work correctly, drawing the results for the school year selected on the form referenced.

Although I don't think it pertains, here is the code:


'Create The Recordset
If Me.Frame11 = 1 Then
strQueryName = "ExcelHS"
GroupTitle = "High School"
Else
strQueryName = "ExcelMS"
GroupTitle = "Middle School"
End If
Set objRst = Application.CurrentDb.OpenRecordset(strQueryName)

Any ideas would be welcome. Thanks
 
  1. When posting code, do not post snippets but the entire subroutine
  2. When posting code, use code tags. Click on Advanced, select code, press #
  3. If you have error handling then disable it, and run your code again. If you had proper error handling you'd receive a message and would ask a different question :D
 

Users who are viewing this thread

Back
Top Bottom