hwmueller
Technical User
- Jan 16, 2001
- 155
Hi
I am a new user of Microsoft Access and have a question concerning the use of module code. I am trying to program a button in a form which allows the user to see a preview of a report of that form. The problem is that I can only get the button to show all pages in that report instead of the one actually being viewed. The problem I think lies with the data type being used by the primary key i.e 'text' and not 'AutoNumber'. The code I have written so far is as follows:
Private Sub Customer_Sheet_Preview_Click()
On Error GoTo Err_Customer_Sheet_Preview_Click
If IsNull(Me![Customer ID]) Then
MsgBox "Please enter customer details before clicking preview."
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenReport "Customer_Sheet_Preview", acPreview, , "[Customer ID] = " & [Customer ID]
End If
Exit_Customer_Sheet_Preview_Click:
Exit Sub
Err_Customer_Sheet_Preview_Click:
MsgBox Err.Description
Resume Exit_Customer_Sheet_Preview_Click
End Sub
When running the code I get the following error message:
"Data type mismatch in criteria expression".
What is wrong??!! Thanks for your help in advance!
Hans Mueller
I am a new user of Microsoft Access and have a question concerning the use of module code. I am trying to program a button in a form which allows the user to see a preview of a report of that form. The problem is that I can only get the button to show all pages in that report instead of the one actually being viewed. The problem I think lies with the data type being used by the primary key i.e 'text' and not 'AutoNumber'. The code I have written so far is as follows:
Private Sub Customer_Sheet_Preview_Click()
On Error GoTo Err_Customer_Sheet_Preview_Click
If IsNull(Me![Customer ID]) Then
MsgBox "Please enter customer details before clicking preview."
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenReport "Customer_Sheet_Preview", acPreview, , "[Customer ID] = " & [Customer ID]
End If
Exit_Customer_Sheet_Preview_Click:
Exit Sub
Err_Customer_Sheet_Preview_Click:
MsgBox Err.Description
Resume Exit_Customer_Sheet_Preview_Click
End Sub
When running the code I get the following error message:
"Data type mismatch in criteria expression".
What is wrong??!! Thanks for your help in advance!
Hans Mueller