Hi folks,
I'm struggling to get my Access 2003 database to work the way I imagined it might. Whether this is a limitation of access or maybe I'm coming at it from the wrong angle, I'm not sure, I am hoping one of you may help.
I am collecting data about scientific protocols and have several tables containing all the data I require. I have created a query to bring some of this information together in one table and want to use this to create a printable report.
I want to print the specific report that is being viewed in the form from the query table. I have been able to filter to specific reports when creating a report directly from a single table, pointing to the primary key "[ID]". However, this doesn't seem to work when I point my form to the report where data is taken from the query table.
I get a popup asking to enter the parameter value, can't quite understand why it works fine for one report, but not the other.
I did add the ID field to the query and also I have swapped the report name to reflect the report's name.
I have a button containing the following code;
Any idea what might be going wrong here?
I'm struggling to get my Access 2003 database to work the way I imagined it might. Whether this is a limitation of access or maybe I'm coming at it from the wrong angle, I'm not sure, I am hoping one of you may help.
I am collecting data about scientific protocols and have several tables containing all the data I require. I have created a query to bring some of this information together in one table and want to use this to create a printable report.
I want to print the specific report that is being viewed in the form from the query table. I have been able to filter to specific reports when creating a report directly from a single table, pointing to the primary key "[ID]". However, this doesn't seem to work when I point my form to the report where data is taken from the query table.
I get a popup asking to enter the parameter value, can't quite understand why it works fine for one report, but not the other.
I did add the ID field to the query and also I have swapped the report name to reflect the report's name.
I have a button containing the following code;
Code:
Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "Pharmacy form", acViewPreview, , strWhere
End If
End Sub
Any idea what might be going wrong here?