Hi all,
Access 2k
I've created a form that contains a list of all reports in my database and all forms that are associated with the reports. This information is contained in a table called tbl_Reports and I use the MSysObjects to get the information on both reports and forms contained in the db.
The forms is a continuous form that list all the records in the tbl_reports table. I've inserted a button into every line that opens up whatever form is associated with that report. This works okay.
The problem I am having, is that some of my reports do not require any parameters so a form is not required. I wrote the following if statement that checks if the report has a form, and if it doesn't then just go straight to opening up the report but I always get an invalid use of null because there is the FormName field is blank.
Can anyone see where I am going wrong?
Dim FName As String
Dim RName As String
' FormName is the name of the form
FName = Forms!frm_ReportsSub!FormName
' ReportCode is the name of the report
RName = Forms!frm_ReportsSub!ReportCode
If IsNull(FName) Then 'Check if FormName is blank
DoCmd.OpenReport RName 'If it is then open the report instead
Else
DoCmd.OpenForm FName 'If not then open the form
End If
Thanks, Tadynn
Access 2k
I've created a form that contains a list of all reports in my database and all forms that are associated with the reports. This information is contained in a table called tbl_Reports and I use the MSysObjects to get the information on both reports and forms contained in the db.
The forms is a continuous form that list all the records in the tbl_reports table. I've inserted a button into every line that opens up whatever form is associated with that report. This works okay.
The problem I am having, is that some of my reports do not require any parameters so a form is not required. I wrote the following if statement that checks if the report has a form, and if it doesn't then just go straight to opening up the report but I always get an invalid use of null because there is the FormName field is blank.
Can anyone see where I am going wrong?
Dim FName As String
Dim RName As String
' FormName is the name of the form
FName = Forms!frm_ReportsSub!FormName
' ReportCode is the name of the report
RName = Forms!frm_ReportsSub!ReportCode
If IsNull(FName) Then 'Check if FormName is blank
DoCmd.OpenReport RName 'If it is then open the report instead
Else
DoCmd.OpenForm FName 'If not then open the form
End If
Thanks, Tadynn