Results 1 to 5 of 5

Thread: [RESOLVED] Moving control to previous record field

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Poulsbo, WA
    Posts
    60

    Resolved [RESOLVED] Moving control to previous record field

    I hope this is the right forum for this...

    I have an Access 2000 sub-form with a bit of VB programming behind it. The fields are layed out like this -

    Field1 Field2 Field3

    Fields 2 and 3 have some error checking that works fine. Problem I have is that when Field3 finishes it's error checking it creates a new record and goes to Field1 of the new record, leaving a null value in Field3 of the previous record.

    Can I somehow do the error checking in Field3 and then have the focus stay there?

    Thanks all!
    John

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Moving control to previous record field

    post the code u are using for error check...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Poulsbo, WA
    Posts
    60

    Re: Moving control to previous record field

    Here it is. But the error checking works fine. What they're asking for is to have the focus stay in Field3(the last one). right now, it goes through and whether or not it fails the check it cycles through to a new record.

    **Code Start**
    Lng = CInt(Left(Me![Longitude], 3))
    Min = CInt(Mid(Me![Longitude], 5, 2))

    If Lng < 181 Then
    If Lng = 180 And Min > 0 Then
    MsgBox "Minutes must be between 00 and 59", vbOKOnly, "Incorrect Entry"
    Me![Longitude] = Null
    Me![Longitude] = Null
    Me.Controls("Longitude").SetFocus
    Exit Sub
    End If
    Else:
    MsgBox "Degrees must be between 000 and 180", vbOKOnly, "Incorrect Entry"
    Me![Longitude] = Null
    Me![Longitude] = Null
    Me.Controls("Longitude").SetFocus
    Exit Sub
    End If

    If Min < 60 Then
    Else:
    MsgBox "Minutes must be between 00 and 59", vbOKOnly, "Incorrect Entry"
    Me![Longitude] = Null
    Me![Longitude] = Null
    Me.Controls("Longitude").SetFocus
    Exit Sub
    End If


    If Right(Me![Longitude], 1) <> "E" Then
    If Right(Me![Longitude], 1) <> "W" Then
    MsgBox "This is not a valid Longitude", vbOKOnly, "Invalid Entry"
    Me![Longitude] = Null
    Me.Controls("Longitude").SetFocus
    Exit Sub
    End If
    End If
    Me![Longitude] = UCase(Me![Longitude])

    Check1 = Mid(Me![Longitude], 1, 1)
    Check2 = Mid(Me![Longitude], 2, 1)
    Check3 = Mid(Me![Longitude], 3, 1)
    Check4 = Mid(Me![Longitude], 5, 1)
    Check5 = Mid(Me![Longitude], 6, 1)

    Sum2 = Right((Check1 + Check2 + Check3 + Check4 + Check5), 1)
    Me![CheckLong] = Sum2

    **End of Code**

    Data can fail the check at a few spots, and it works beautifully. I've even made it return focus to Fields 1 and 2 using a On_Enter action in the next field over, for example -

    If the checks fail in Field1, it will produce a null value and move to Field2.
    After entering Field2, if a null value is present in Field1, it returns focus to Field1.

    There is a simalar action in the On_Enter action in Field3 looking for a null value in Field2. I just ran out of controls to set up the On_Enter action in.

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Moving control to previous record field

    on exit event? lost focus?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Poulsbo, WA
    Posts
    60

    Re: Moving control to previous record field

    I'm an idiot. Lost_Focus worked like a charm. I'm going to go ahead and set up the rest like that as well...

    Thanks a buch!
    John

Posting Permissions

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



Click Here to Expand Forum to Full Width