Avoid enter parameter value

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

Guest

hello,
i'm trying to write my first report, and i want avoid to enter a parameter
value in the input message. here is my code:
a) param1 is the parameter i have in my query
Dim stCriteria As String
Dim stDocName As String
DIM param 2 as string
param2 = "clx90001"
stDocName = "str1"
stCriteria = "[param1]=" & param2
DoCmd.OpenReport stDocName, acViewPreview, , stCriteria
 
Hi Carlos
The parameter you are using is a string type, so it should be define
deferently
stCriteria = "[param1]='" & param2 & "'"

When you define a number type, it should be
stCriteria = "[param1]=" & param2
====================================
Now, if param1 is not the field name in the table that you are trying to
filter on, then change it to
stCriteria = "[FieldName In the table]='" & param2 & "'"
=====================================
Remove the parameters from the query or the SQL that the report id bound to
=====================================
In the End, the code can look like that
Dim stCriteria As String
Dim stDocName As String
stDocName = "str1"
stCriteria = "[param1]='clx90001'"
DoCmd.OpenReport stDocName, acViewPreview, , stCriteria
=======================================
Or, to make it realy short
DoCmd.OpenReport "str1", acViewPreview, , "[param1]='clx90001'"
 
Back
Top