Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maximum length of WhereCondition in DoCmd.OpenForm comand 1

Status
Not open for further replies.

jwalacha

Programmer
Aug 2, 2002
33
US
Hello,
Can someone confirm the character limit of the wherecondition in the command:
DoCmd.OpenForm stDocName, , , stWhereclause ?
I have defined my variable stWhereclause as a string (also tried it defining it as a variant) and I run into a 3075 syntax error when my variable is greater than 255 characters!
The help file for the openform command tells me that the maximum length of the WhereCondition is 32,768. But clearly this is not true in my case!
Any input in this matter would be helpful as I will have a wherecondition that is greater than 255 characters.
Thank you,
Jay.
 
This may apply to you:
Microsoft said:
Note The maximum length of the Where Condition argument is 256 characters. If you need to enter a more complex SQL WHERE clause longer than this, use the OpenForm method of the DoCmd object in Visual Basic instead. You can enter SQL WHERE clause statements of up to 32,768 characters in Visual Basic.
 
If I understand correctly, the above statement reads that I should use the OpenForm method of the DoCmd object in VB as opposed to the OpenForm method in MS Access VBA!
IF that is the case, I need to look for an alternate method to open a form with the dynamically generated Where clause while staying within the MS Access environment.
Can you please suggest any method to accomplish this?
Thanks again.
 
Sorry, I left out an important bit of the quote, or left in an unimpirtant bit. [blush]
256 applies to macros, the other bit was to
"confirm the character limit of the wherecondition in the command ..."
Perhaps you can post the Where clause in case someone can spot a problem or change?

 
Remou,

I was creating my wherecondition dynamically, And as I got ready to paste my where clause, I noticed my error in creating the dynamic where clause! (in certain scenerios, I didn't enter a space between two OR conditions!)

I modified my code and everything works fine now. Thank you for drawing my attention to my code.

This proves that there indeed ISN'T a 255 character limit for the where condition when using the DoCMD.OpenForm command.

Best Regards,
Jay.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top