WhereCondition of DoCmd.OpenForm

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

Guest

I have the following VBA codes. Sometimes it works but sometimes it is not

The run-time error is '3075' but I have no idea what is wrong
strWhere = gstrOrde
gstrWhereOrder = "[OrderNumber] IN (" & strWhere & ")
DoCmd.OpenForm FormName:="frmOrder", WhereCondition:=gstrWhereOrder
 
Add a Debug.Print gstrWhereOrder just before the call to DoCmd. When the
code fails, examine the value printed to the Immediate window. The problem
may become clear then. If not, try posting again including that value.

It may also help to post the actual text of the error message. Sometimes
it's possible to look up an error message given the error number, but the
message associated with error number 3075 is "|1 in query expression '|2'."
"|1" is a placeholder that is filled in at run-time with the type of error
that occurred, while "|2" is a placeholder that is filled in with the text
of the expression. So it's difficult to determine exactly what's going wrong
given just the number without the message.

--
Brendan Reynolds (MVP)

Chris said:
I have the following VBA codes. Sometimes it works but sometimes it is not.

The run-time error is '3075' but I have no idea what is wrong.
strWhere = gstrOrder
gstrWhereOrder = "[OrderNumber] IN (" & strWhere & ")"
DoCmd.OpenForm FormName:="frmOrder",
WhereCondition:=gstrWhereOrder
 
Thanks. I found that there is a mistake in my filiter. I had left out quots. It should be [OorderNumber] IN ('Order 1'). but how do I know if the Wherecondition is working? After I fix it, there is no more runtime error and the called form has been shown up. But it seems the WhereCondition (I mean the record source query) is not working.
 
I don't have enough information to answer, Chris. I'd need an example
including the value of the WhereCondition argument, the expected result, and
the actual result.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

Chris said:
Thanks. I found that there is a mistake in my filiter. I had left out
quots. It should be [OorderNumber] IN ('Order 1'). but how do I know if
the Wherecondition is working? After I fix it, there is no more runtime
error and the called form has been shown up. But it seems the
WhereCondition (I mean the record source query) is not working.
 
Back
Top