Need Urgent Help ....

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to print a report on click of a button, for which I have the following
code OnClick of a button ...

DoCmd.OpenReport stDocName, acViewPreview, "APPENDIX A-2",
"[CONTRACT_NO]=" & "'" & Me![CONTRACT_NO] & "'" & " and [TO_NO]= " & "'" &
StrTO_NO & "'"


If I remove the following
& " and [TO_NO]= " & "'" & StrTO_NO & "'"


it works fine, but after adding the above text, I get data type mismatch.
actually [TO_NO] is numeric fields linked to a sql server table.
I am converting it to String using - Dim StrTSO_NO As String

I get "Data Type Mismatch in Criteria Expression"

I tried both without the converted variable and with the converted variable,
both times I get the same error.

I am frustrated, can someone please help me?

Thank you,
-Me
 
If it is a numeric field in the database, it has to be addressed as a number.
You will need to remove the qoutes around it in your Where Condition:

"[CONTRACT_NO]=" & "'" & Me![CONTRACT_NO] & "'" & " and [TO_NO]= " & StrTO_NO
 
Thanks a million Klatuu, it works for me.
-Me


Klatuu said:
If it is a numeric field in the database, it has to be addressed as a number.
You will need to remove the qoutes around it in your Where Condition:

"[CONTRACT_NO]=" & "'" & Me![CONTRACT_NO] & "'" & " and [TO_NO]= " & StrTO_NO


Me said:
I want to print a report on click of a button, for which I have the following
code OnClick of a button ...

DoCmd.OpenReport stDocName, acViewPreview, "APPENDIX A-2",
"[CONTRACT_NO]=" & "'" & Me![CONTRACT_NO] & "'" & " and [TO_NO]= " & "'" &
StrTO_NO & "'"


If I remove the following
& " and [TO_NO]= " & "'" & StrTO_NO & "'"


it works fine, but after adding the above text, I get data type mismatch.
actually [TO_NO] is numeric fields linked to a sql server table.
I am converting it to String using - Dim StrTSO_NO As String

I get "Data Type Mismatch in Criteria Expression"

I tried both without the converted variable and with the converted variable,
both times I get the same error.

I am frustrated, can someone please help me?

Thank you,
-Me
 
Back
Top