Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Evansville, Indiana, USA
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a Visual Studio project that I am trying to open a form in the click event of a button. When I try DoCmd.OpenForm "frmName" the compiler says docmd is an error. How do I make DoCmd work?
    Thanks

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by bzimmer View Post
    When I try DoCmd.OpenForm "frmName" the compiler says docmd is an error. How do I make DoCmd work?
    I think you need to use Object.Method notation, such as MyForm.Display (note: that is conceptual pseudocode only, not actual code).

  4. #3
    Lounger
    Join Date
    Dec 2009
    Location
    Burlington, VT
    Posts
    31
    Thanks
    2
    Thanked 1 Time in 1 Post
    You use the .Show() Method. I usually also hide the current form so as to not fill up the screen with sub forms:
    Code:
    Private Sub cmdNewPO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNewPO.Click
            frmCreatePO.Show()
            Me.Hide()
        End Sub

  5. #4
    New Lounger
    Join Date
    Apr 2010
    Location
    Naperville, IL
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can also use Form.ShowDialog to open the form as a modal form that the user has to close before continuing to use the application.

    I use .ShowDialog frequently for database applications that require the user to complete filling out all of the text boxes, etc on a form or click a Close/Cancel button to cancel any adding/editing of data on the form. If your app is "form heavy" using .Show can get you into trouble as well as potentially making the app less maintainable.
    My name is Jeff Penchoff and I'm a computer programmer by profession.

    My LLC is Web Success Partners where I market various products and work with a large community of website owners. Stop by and check us out!

Posting Permissions

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