Results 1 to 5 of 5

Thread: goto control

  1. #1
    Join Date
    Nov 2006
    Posts
    10

    Unanswered: goto control

    I have the following code (that doesn’t work properly)

    The msgBox open as it should but after the choise “Nej” (vbNo) it supposed to go to specified control. I have tried with “doCmd.GoTo…. and “SetFocus” but it doesn’t work. The cursor goes to next field. What am I doing wrong??

    Private Sub GipsFlow_AfterUpdate()

    Dim matning As Single
    matning = GipsFlow


    If matning > 29.999 Or matning < 9.999 Then

    If MsgBox("Du har angivit " & matning & " ton/timme i gipsmatning som ligger utanför gränsvärdena (10-30t/timme!)" & vbCrLf & "Vill du verkligen använda dig " _
    & " av detta värde?, klicka Ok. För att avbryta och skriva nytt värde, klicka Nej", vbCritical + vbYesNo,") = vbNo Then

    Me.GipsFlow.SetFocus

    End If
    End If


    End Sub

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Try using this instead:

    Me!GipsFlow.SetFocus
    Inspiration Through Fermentation

  3. #3
    Join Date
    Mar 2007
    Posts
    277
    It looks like you are trying to hold the focus in the current control if the answer is no. You have already discovered that you can not set the focus to the current control in the AfterUpdate event of that control and expect to keep the focus. The current control already has the focus so it will not work. Move your code to the BeforeUpdate event and set Cancel = True if the answer is vbNo.
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  4. #4
    Join Date
    Nov 2006
    Posts
    10

    Cool

    Thanks!!!!

    It works!!

    BG

    Gostap

  5. #5
    Join Date
    Mar 2007
    Posts
    277
    Glad I could help.
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

Posting Permissions

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