Curious error message on opening a report.

  • Thread starter Thread starter Frank Martin
  • Start date Start date
F

Frank Martin

I want to open a report RptCustPricelist to display the specific customer
showing on the FrmPriceList.
I am using the following code:

***

Private Sub Command48_Click()

On Error GoTo Err_Command48_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "RptCustPricelist"

stLinkCriteria = "[AddressesID]=" & "'" & Me![AddressesID] & "'"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
DoCmd.RunCommand acCmdZoom75
Exit_Command48_Click:
Exit Sub

Err_Command48_Click:
MsgBox Err.Description
Resume Exit_Command48_Click

End Sub

***
(AddressesID is an autonumber)

The error message is:

"Runtime error 3464
Datatype mismatch in criteria expression".

I just can't see where this is. Can someone help?
Frank
 
You are coding as if AddressesID is text. Try
stLinkCriteria = "[AddressesID]=" & Me![AddressesID]
 
Many thanks. This fixed it fine.
Regards Frank



Duane Hookom said:
You are coding as if AddressesID is text. Try
stLinkCriteria = "[AddressesID]=" & Me![AddressesID]

--
Duane Hookom
MS Access MVP
--

Frank Martin said:
I want to open a report RptCustPricelist to display the specific customer
showing on the FrmPriceList.
I am using the following code:

***

Private Sub Command48_Click()

On Error GoTo Err_Command48_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "RptCustPricelist"

stLinkCriteria = "[AddressesID]=" & "'" & Me![AddressesID] & "'"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
DoCmd.RunCommand acCmdZoom75
Exit_Command48_Click:
Exit Sub

Err_Command48_Click:
MsgBox Err.Description
Resume Exit_Command48_Click

End Sub

***
(AddressesID is an autonumber)

The error message is:

"Runtime error 3464
Datatype mismatch in criteria expression".

I just can't see where this is. Can someone help?
Frank
 
Back
Top