Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Location
    Walnut Cove, NC
    Posts
    101

    Unanswered: Executing one line of code at a time in a procedure

    I have 2 forms that have 6 signature combo box fields on each of them. I have created an On Click procedure. When the combo box is clicked, I have a popup form I want to activate. The popup form asks for a userid and password, if the password is correct, I am passing the person's name to the combo box. Here is my code for the combo box.

    Private Sub ProdEng_Click()
    'test for Signature approval, if authorized, sign their name

    DoCmd.OpenForm "Password_Protect"

    Me!ProdEng = getpwd.FirstName + " " + getpwd.LastName
    End Sub

    I need for the "DoCmd.OpenForm" to process first. The getpwd.firstname and lastname will be assigned in the popup form "Password_Protect".

    When I click on the combo box, all of the sub commands are immediately executed. How can I force it to open the Password_Protect form and not execute the line Me!ProdEng= getpwd.FirstName + " " + getpwd.LastName until the popup form closes?


    Thanks,

    Sherry

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb

    No, you can not do that, but you can let ACCE$$ wait for one or two minutes. Try the next code

    PHP Code:
    Private Declare Sub sapiSleep Lib "kernel32" _
            Alias 
    "Sleep" _
            
    (ByVal dwMilliseconds As Long)

      
    Sub sSleep(lngMilliSec As Long)
         If 
    lngMilliSec 0 Then
             Call sapiSleep
    (lngMilliSec)
         
    End If
      
    End Sub

      Sub sTestSleep
    ()
        Const 
    cTIME 10000 'in MilliSeconds 10 seconds
          Call sSleep(cTIME)
          MsgBox "Before this message, I was snoring for " _
              & cTIME & " Milliseconds."
      End Sub 

  3. #3
    Join Date
    Jan 2004
    Location
    Lancashire, UK
    Posts
    33
    Quote Originally Posted by hammbakka
    No, you can not do that, but you can let ACCE$$ wait for one or two minutes. Try the next code
    Sorry, I disagree. Try the following code to open the form:

    Private Sub ProdEng_Click()
    'test for Signature approval, if authorized, sign their name
    DoCmd.OpenForm "Password_Protect", , , , , acDialog
    'This line will not run until the above form is closed
    Me!ProdEng = getpwd.FirstName + " " + getpwd.LastName

    End Sub

    Opening a form with the acDialog effectively pauses execution of the code in the calling procedure.

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Yes you are right, using the acDialog while opening a form lets you do it....

  5. #5
    Join Date
    Jan 2004
    Location
    Walnut Cove, NC
    Posts
    101
    Thank you VERY much! The ,,,,,acdialog is exactly what I needed.


    Sherry

Posting Permissions

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