Results 1 to 4 of 4
  1. #1
    dweekley is offline Advanced Beginner
    Windows XP Access 2002 (version 10.0)
    Join Date
    May 2010
    Posts
    52

    Check Textbox for no value

    Hello

    I am trying to check that a textbox value is empty prior to a change. If it is empty I do not want the messege to trigger.

    I currently have the following in the 'On Change' Event.

    Private Sub txtSON_Change()
    'Alert when changing


    If Len(Me.txtSON.Value) = 0 Then GoTo EmptyExit

    MsgBox "You are about to change the 'Shop Order Number'" _


    & Chr$(13) _
    & "Be certain number matches appropriate part number.", vbOKOnly, "Change Alert"

    EmptyExit:


    Exit Sub


    End Sub

    The messege is triggering even when there is no value in the textbox.

  2. #2
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Modify the If to: If Len(Me.txtSON.Value & "") = 0 Then GoTo EmptyExit

    and move it to the BeforeUpdate or AfterUpdate event for the control.

    imo, as a user I would be very annoyed with this pop-up.

  3. #3
    dweekley is offline Advanced Beginner
    Windows XP Access 2002 (version 10.0)
    Join Date
    May 2010
    Posts
    52
    Thanks that did the trick. what does the & "" cover?

    Just tried it. And yes your right. I need to tweak it a bit now. Most like a Case Select. The textbox is either empty or has 5 digits in it. So it will now trigger on digits 2,3,4 and 5 now.

    Thanks

  4. #4
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    If the value of the control is Null, just checking for Len of Null would return an unknown value, not 0. Thus appending an empty string to it then presents a known value.

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

Similar Threads

  1. Check textbox's old value.
    By Homegrownandy in forum Programming
    Replies: 2
    Last Post: 10-28-2015, 04:53 AM
  2. Replies: 3
    Last Post: 05-22-2014, 10:19 AM
  3. Replies: 4
    Last Post: 02-28-2013, 10:43 AM
  4. Replies: 3
    Last Post: 01-09-2013, 10:13 AM
  5. Replies: 1
    Last Post: 06-01-2009, 04:05 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