Results 1 to 8 of 8
  1. #1
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368

    docmd.gotocontrol after undo

    i have a field wich asks a question on the before update event.

    Like "are you sure you want to alter the data ?"

    Hitting yes will change the input, hitting no will cancel the imput with

    Cancel = True


    Me.MyFieldName.Undo

    When they select "no" i want the focus to go to another field on my form.
    Appearently, i cant do this because i get the error saying its impossible to move the focus when the
    data is not saved.

    Offcourse i tryed to save the form and control programmaticly with "docmd.save" and other methods.
    None of my solutions work though.

    Any genius here that knows a workaround ?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try using the AfterUpdate event instead of the BeforeUpdate event. You can't cancel it but you can still do the "Me.MyFieldName.Undo" and then move the focus wherever you want.

  3. #3
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    That doesnt work because the data has allready been saved into the table with the afterupdate.
    Really strange this by the way because if i click no and the undo is done. I can just click my mouse to the field of my desire, But if i try to do that programmaticly it doesnt work..

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You cannot move the focus in the BeforeUpdate event, sorry. You *can* however access the Me.MyControlName.OldValue to restore the control to what it was originally in tha AfterUpdate event.

  5. #5
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Still no luck im afraid

    Code:
    Private Sub fldPlaatsNaamVestiging_AfterUpdate()
    Dim LResponse As Integer
    Dim strSQL As String
    LResponse = MsgBox("Om te zoeken op winkelnaam gebruik het veld 'zoek winkel'" _
    & vbCrLf & "Weet je zeker dat je de naam van de vestiging wilt veranderen ???" _
    & vbCrLf & "Klik ja om deze naam te veranderen of nee om te annuleren", vbYesNo, "Naam vestiging aanpassen")
    If LResponse = vbYes Then
    Exit Sub
    Else
    End If
    If LResponse = vbNo Then
     Me.fldPlaatsNaamVestiging.OldValue
     End If
    Forms("frmObjecten1").SetFocus
    Forms("frmObjecten1").Controls("Filterplaatsnaam").SetFocus
    End Sub
    Maybe posting my code will shed some light (i hope)
    Thanks for looking at my problem btw

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try this code:
    Code:
    Private Sub fldPlaatsNaamVestiging_AfterUpdate()
       If MsgBox("Om te zoeken op winkelnaam gebruik het veld 'zoek winkel'" _
                 & vbCrLf & "Weet je zeker dat je de naam van de vestiging wilt veranderen ???" _
                 & vbCrLf & "Klik ja om deze naam te veranderen of nee om te annuleren", vbYesNo, _
                 "Naam vestiging aanpassen") = vbNo Then
          Me.fldPlaatsNaamVestiging = Me.fldPlaatsNaamVestiging.OldValue
       End If
       Me.Filterplaatsnaam.SetFocus
    End Sub

  7. #7
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Thanks Ruralguy, That works like a charm

    Much appreciated mate !

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You're very welcome. You did notice I shortened it up quite a bit. The other code was not necessary.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 03-12-2013, 01:41 PM
  2. GoToControl and SetFocus question
    By bgephart in forum Forms
    Replies: 5
    Last Post: 08-29-2012, 12:10 PM
  3. Undo one action only
    By zoooza84 in forum Access
    Replies: 5
    Last Post: 08-21-2011, 03:04 PM
  4. Help with gotocontrol, activecontrol
    By k9drh in forum Forms
    Replies: 5
    Last Post: 04-21-2011, 10:12 AM
  5. Issues with DoCmd.GoToControl
    By RaMcHiP in forum Programming
    Replies: 1
    Last Post: 05-09-2009, 08:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums