Results 1 to 9 of 9
  1. #1
    5 Star Lounger
    Join Date
    Jan 2002
    Location
    Midlothian, Virginia, USA
    Posts
    874
    Thanks
    0
    Thanked 2 Times in 1 Post

    OpenForm Syntax Problem (Access 2000)

    I have form in datasheet mode that displays the contents of a table. It works fine when I open it manually. However, I want to open it from some code. I tried this:

    DoCmd.OpenForm ("FormName")

    That does open the form but it opens it in form mode and shows only the first line from the table. I suspect that I have to add the acFormDS value in the second parameter -- I'm assuming that DS stands for DataSheet in that constant name -- but I haven't been able to find any acceptable way to include that argument! I've tried all kinds of things and I always get an error about expecting "=".

    Can someone tell me the proper syntax for opening the form in datasheet mode?

    Thanks,
    Bill

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: OpenForm Syntax Problem (Access 2000)

    What happens if you just have:

    DoCmd.OpenForm "FormName", acFormDS

    This works for me.
    Regards
    John



  3. #3
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OpenForm Syntax Problem (Access 2000)

    Try setting the Form's Default View property to Datasheet.
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: OpenForm Syntax Problem (Access 2000)

    That won't work - DoCmd.OpenForm ignores the Datasheet setting in the Default View property and opens a form in Form view. so you must explicitly specify acFormDS.

  5. #5
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OpenForm Syntax Problem (Access 2000)

    You would be better off creating your form to look like a datasheet and setting its default view to continuous forms. You can do that by placing all your fields on one row and the field labels in a form header. You have alot more control over data entry by users from a form view than from a datasheet view.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: OpenForm Syntax Problem (Access 2000)

    I second that! For almost all situations, a continuous form is better than a datasheet form.

  7. #7
    5 Star Lounger
    Join Date
    Jan 2002
    Location
    Midlothian, Virginia, USA
    Posts
    874
    Thanks
    0
    Thanked 2 Times in 1 Post

    Re: OpenForm Syntax Problem (Access 2000)

    John,

    That works for me too! The prompts that show up when you type in the OpenForm command show the parameters in parentheses so I entered them that way. That obviously wasn't the right thing to do.

    Thanks,
    Bill

  8. #8
    5 Star Lounger
    Join Date
    Jan 2002
    Location
    Midlothian, Virginia, USA
    Posts
    874
    Thanks
    0
    Thanked 2 Times in 1 Post

    Re: OpenForm Syntax Problem (Access 2000)

    Yes, I already had it set to use only the datasheet view but that didn't help.

    Bill

  9. #9
    5 Star Lounger
    Join Date
    Jan 2002
    Location
    Midlothian, Virginia, USA
    Posts
    874
    Thanks
    0
    Thanked 2 Times in 1 Post

    Re: OpenForm Syntax Problem (Access 2000)

    Judy,

    Yes, I normally use a Continuous Form instead of a datasheet but in this case it is going to be for display only with no entries or selections or anything possible by the user so I figured datasheet would work OK.

    Thanks,
    Bill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •