Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Dec 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Text Box Length ( Access 2003)

    I have a database that I'm building and it is really simple except for I can't get my textbox to run my SQL command after it reaches 10 digits.

    I don't have my coding with me, but it's something like this.
    Private Sub RsUpdate()
    Dim Rs As New ADODB. Recordset
    Set Rs.ActiveConnection = CurrentProject.Conection
    Docmd.runsql ( INSERT INTO ...
    ...)

    the update works perfectly fine if i put it onto a command button.

    I tried putting this in my textbox code but it's not working. It will work after I take the focus out of the textbox.

    Private Sub Text4 AfterUpdate and KeyUp
    IF Len(Text4.text) = 10 Then
    Call RsUpdate
    End If

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Text Box Length ( Access 2003)

    Welcome to Woody's Lounge!

    Automatically running an append query when the text has reached length 10 is dangerous - it leaves the user no room for correcting errors, and the code could run repeatedly if the user types another character then deletes it, etc., so I strongly recommend against doing it that way. I'd go with the After Update event (i.e. when the user exits the text box) or preferably, the On Click event of a command button.

    If you really want to act when the length is 10, you could use the On Change event of the text box.

  3. #3
    New Lounger
    Join Date
    Dec 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text Box Length ( Access 2003)

    How do I stop the message from coming up that says you are about to append a message do you want to do this? Also, thanks a lot HansV, it helped tremendously.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Text Box Length ( Access 2003)

    Insert the following line above the line with DoCmd.RunSQL:

    DoCmd.SetWarnings False

    and below it

    DoCmd.SetWarnings True

  5. #5
    New Lounger
    Join Date
    Dec 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text Box Length ( Access 2003)

    Awesome, thanks again. This should be my last question. It will be fairly simplry probably.

    In my table I have 2 fields one for names and the other one for 10 digit numbers. I need the 10 digit number field to start with a zero and it has to be in text format, can't be in number format.

    I've tried chaning the Format to 0000000000
    and the Input mask to 0000000000;0;

    it doesn't work though. Any thoughts would be great.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Text Box Length ( Access 2003)

    Make it a text field of length 10.
    Set the Input Mask property to <code>0000000000;0;_</code>
    The before the first 0 means that this 0 is a literal character, not a placeholder for any digit.

  7. #7
    New Lounger
    Join Date
    Dec 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text Box Length ( Access 2003)

    You Sir are a genius for lack of better words. Thanks for the help.

    Sincerely,
    Douglas

Posting Permissions

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