Results 1 to 2 of 2

Thread: Forms open

  1. #1
    Join Date
    Apr 2002
    Posts
    168

    Unanswered: Forms open

    Sub cmdOpen_Click()
    docmd.openform "Form2"
    Msgbox("A")
    End Sub

    This cmdOpen is in Form1. My question is when I click on
    cmdOpen, Form2 is open and then the msgbox pops up
    right away. What I actually want is when I click on
    cmdOpen, the Form2 is open, and only when I click
    cmdCancel in Form2, the Form2 is close and then the code
    msgbox is run. Can anyone give suggestion ?

    Thanks.

    NB: Should I just put the msgbox in the cmdCancel_Click instead ? That's what I have been doing.


    Just like when I use common dialog control, for example :

    Private Sub cmdOpen_Click()
    dlgCommon.ShowOpen
    Me.txtFileName = dlgCommon.FileName
    End Sub

    It waits until I click on Save or Cancel, then continues
    to the next code rather than assigning the value right
    away.

  2. #2
    Join Date
    Feb 2002
    Posts
    403
    Sub cmdOpen_Click()
    docmd.openform "Form2"
    Msgbox("A")
    End Sub

    Read this code.

    Sub cmdOpen_Click()

    This event is to occur when cmdOpen is clicked.

    docmd.openform "Form2"

    The event to occur when cmdOpen is clicked is to open a form called Form2.

    Msgbox("A")

    After opening the form, the next event is to pop up a message box with the letter A in it.

    End Sub

    Now Access is finished. So form2 is open and displayed and a Messagebox with A is displayed as well, as this is what your code has told Access to do.

    Is this what you want to happen?

    Have a look at some basic programming books or on line courses. When I started to dabble in code I combined books like Access Bible with on line courses for visual basic, (Note: not Visual Basic for Applications). There is no substitute for training, no matter what your budget somewhere there is some training that at a minimum will get you started.

Posting Permissions

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