Access ADP DoCmd.OpenForm

Posted on 2007-10-16
Last Modified: 2013-12-05
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
Question by:Daren Anderson, MSIS
    LVL 29

    Expert Comment

    Your example has nothing to do with ADP - you are trying to access a form variable.
    LVL 77

    Expert Comment

    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.
    LVL 44

    Accepted Solution

    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 & "'"

    Author Comment

    by:Daren Anderson, MSIS
    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

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now