• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 858
  • Last Modified:

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
0
Daren Anderson, MSIS
Asked:
Daren Anderson, MSIS
1 Solution
 
BadotzCommented:
Your example has nothing to do with ADP - you are trying to access a form variable.
0
 
peter57rCommented:
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.
0
 
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 & "'"
0
 
Daren Anderson, MSISAuthor 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
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now