Hello
I'm currently working on a macro for a report. The report shows dates for different categories which the user decides. I'd like my report to show only the categories that the user has decided. The report runs from a query which, obviously, finds the correct date based on the user's criteria
I have the following code:
Code:
Private Sub Report_Open(Cancel As Integer)
Dim counter As Integer
Dim dbs As Database
Dim rst As Recordset
counter = 7
' Open the table of SwitchboardItems, and find
' the first item for this Switchboard Page.
Set dbs = CurrentDb()
strSQL = "SELECT * FROM [SwitchboardItems]"
strSQL = strSQL & " WHERE [ItemNumber] > 1 AND [SwitchboardID]=2"
strSQL = strSQL & " ORDER BY [ItemNumber];"
Set rst = dbs.OpenRecordset(strSQL)
If Not (rst.EOF) Then
If rst![Yes/No] = True Then
Me("Text" & counter).ControlSource = "=[All Expired Query]![Mid(rst![ItemText], 5) & ' Expiry Date']"
Me("Label" & counter).Caption = "=[All Expired Query]![Mid(rst![ItemText], 5) & ' Expiry Date']"
counter = counter + 1
End If
rst.MoveNext
End If
If counter < 14 Then
For I = counter To 14
Me("Text" & I).Visible = False
Me("Label" & I).Visible = False
Next I
End If
Set dbs = Nothing
Set rst = Nothing
End Sub
'All Expired Query' is the query that runs,
'SwitchboardItems' is the table that contains the criteria the user can decide from
The problem i'm getting is the report can find the field, it gives the following error:
The report name 'All Expired Query' you entered in either the property sheet or macro is misspelled or refers to a report that doesn't exist.
Does anyone know the correct syntax I should be using?
Thanks for any help!