Results 1 to 8 of 8
  1. #1
    txtaggers is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2013
    Posts
    4

    Question Error Trapping and stopping Enter from advancing to next control

    OK folks, probably simple answer to this but I'm just missing something. I have a text box that needs validated before moving on to the next control. I can NOT disable the ENTER keys property that allows it to advance to the next field, it's used elsewhere on the form. If the input is invalid and the user hits enter how do I prevent the form from displaying the warning message and advancing to the next control anyway on ENTER? I've tried a dozen variations and EVENT locations with no success. Any great ideas? (using Access 2007 db)



    Here's what I'm working with:

    Private Sub TrnAppointmentTime_AfterUpdate()

    If (TrnAppointmentTime.Value >= "0000" And TrnAppointmentTime.Value <="2359" Then
    Call SOMETHING_ELSE
    Else
    MsgBox "ENTER CORRECT TIME AND OTHER STUFF", vbCritical
    Me.TrnAppointmentTime.SetFocus
    End If

    End Sub

  2. #2
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    put this code it the before update event.

    Dale

  3. #3
    txtaggers is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2013
    Posts
    4

    Didn't work...

    Quote Originally Posted by rzw0wr View Post
    put this code it the before update event.

    Dale
    Tried that earlier on my own and receive a 2108 error... You must save the field before you execute the GoToControl action, the GoToControl method, or the SetFocus method.

  4. #4
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Put an TrnAppointmentTime.undo before the setfocus.

    Dale

  5. #5
    txtaggers is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2013
    Posts
    4
    Nope, still 2108.... here is what I currently have in there:

    Private Sub TrnAppointmentTime_BeforeUpdate(Cancel As Integer)
    If (TrnAppointmentTime.Value >= "0000" And TrnAppointmentTime.Value <= "2359") Then
    Call ToggleCommandButton
    Else
    MsgBox "ENTER A VALID APPOINTMENT TIME" & vbCrLf & "FROM 0000 to 2359", vbCritical
    Me.TrnAppointmentTime.Undo
    Me.TrnAppointmentTime.SetFocus
    'Me.TrnAppointmentTime = Me.TrnAppointmentTime.OldValue <-tried this method also... no luck... kept it here to remind me what I've tried.
    End If
    End Sub

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Try:
    Code:
    Private Sub TrnAppointmentTime_BeforeUpdate(Cancel As Integer)
    If (TrnAppointmentTime.Value >= "0000" And TrnAppointmentTime.Value <= "2359") Then
    Call ToggleCommandButton
    Else
    MsgBox "ENTER A VALID APPOINTMENT TIME" & vbCrLf & "FROM 0000 to 2359", vbCritical
    Cancel = True
    Me.TrnAppointmentTime.SetFocus
    'Me.TrnAppointmentTime = Me.TrnAppointmentTime.OldValue <-tried this method also... no luck... kept it here to remind me what I've tried.
    End If
    End Sub
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    txtaggers is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2013
    Posts
    4
    Still getting a 2108... and a head ache from beating my head against the desk!

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    I think the following link will help: http://www.access-programmers.co.uk/...d.php?t=176480
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Replies: 3
    Last Post: 03-06-2013, 03:52 PM
  2. Trapping for EOF in Control Source
    By drblanston in forum Programming
    Replies: 5
    Last Post: 12-07-2012, 09:38 PM
  3. Append query error trapping
    By tpcervelo in forum Programming
    Replies: 4
    Last Post: 12-22-2011, 10:57 AM
  4. Proper Error Trapping
    By SemiAuto40 in forum Programming
    Replies: 6
    Last Post: 08-11-2011, 10:22 AM
  5. Form and Subform error trapping
    By usmcgrunt in forum Forms
    Replies: 8
    Last Post: 09-12-2010, 11:54 AM

Tags for this Thread

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