Access ADP DoCmd.OpenForm

I just converted my Access 2003 database from a .mdb to an Access ADP and going thru and cleaning up/testing things.  The one thing I cannot get to work is my DoCmd.OpenForm statements - I have tried to modify them but get a run time error 102 Incorrect Syntax near DR - that was on the second statement below.  What is correct syntax now that this is in ADP?  
'DoCmd.OpenForm frmAcctDetails, , , "AcctNo = [forms]![frmAcctPhonebook]![AcctNo]"  -->Original
DoCmd.OpenForm "frmAcctDetails", acNormal, , "[AcctNo]= " & Me!AcctNo
Daren Anderson, MSISPresidentAsked:
Who is Participating?
Leigh PurvisDatabase DeveloperCommented:
Alas, I'd probably have to disagree.

Your example is related to using an ADP, and your original would work in an MDB.
You are free to allow the expression service to evaulate a form reference in an MDB.  Concatenating the explicit value is always your option.  However refering to the expression potentially leaves more to go wrong - but alleviates you of any delimitation requirements (or awareness).
Once in an ADP you're on your own.  Jet's expression service is nowhere to be found so (as you seem to have realized) you have to concatenate a string to pass as a valid filter.
If AcctNo is on the current form - then Me is an acceptable parent object.
However I suspect that the delimitation alleviation which helped you previously has hurt you now.
i.e. Try
DoCmd.OpenForm "frmAcctDetails", acNormal, , "[AcctNo]= '" & Me!AcctNo & "'"
Your example has nothing to do with ADP - you are trying to access a form variable.
To be explicit, the code you mark as 'original' is simply wrong.  It will not work and never has.

The revised code you show is correct assuming you are running it in the form that contains the AcctNo cotrol.
Daren Anderson, MSISPresidentAuthor Commented:
Thank you - that worked perfect.  Now if I could just rid of my error - Data provider or other service returned an E-FAIL status - doesn't come up all the time or doesn't make a difference what program is opened - comes up sporadically.  Back to the research.  Thanks again
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.