Check if field exists on report?

kate10123

Registered User.
Local time
Today, 12:14
Joined
Jul 31, 2008
Messages
185
Hi there,

I am using the following code to filter a report

Private Sub cmdOpCompanyName_Click()
Dim reportname As String
reportname = listReports.Value
' this opens the report in preview mode and you select the customer using the single quotes because Me.cboCompanyName
' returns text and text needs to be surrounded by quotes.
DoCmd.OpenReport reportname, acViewPreview, , "[TutorName]='" & Me.cboCompanyName & "'"
End Sub

The user selects the report from listReports. What I need the code to do though is if the report selected does not contain the filter item i.e TutorName then display message box saying that this report does not contain the filter item.
 
Thanks for that.

Do you know I could put some validation in the following code to display a msgbox if a report is not chosen from the listbox.

I have tried incorporating an If statement but an error message overrides it saying 'invalid use of null'

I tried the following:

Code:
Private Sub student_Click()
Dim reportname As String
Dim DateFilter As String

If listReports.Value IS NULL Then
MsgBox "You must select a report first"
Exit Sub
Else
reportname = listReports.Value
DoCmd.OpenReport reportname, acViewPreview, , "[Date] Between #" & Me.cboFrom & "# And #" & Me.cboTo & "#"
End If
End Sub
 
In VBA, there is just a slight difference ...

Code:
If IsNull(ListReports.Value) Then ...

-dK
 
I have a form with check boxes (yes=1 and no=2) and also option buttons(values -1 and 0). I built a report from the table built from the form. The report has all bound fields from the tbl.

The report has check boxes and I want to show them as 'checked' if the value is 1 for the y/n fields and -1 on the option buttons.
Any suggestions?
 

Users who are viewing this thread

Back
Top Bottom