Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187

    Forms and Scanning

    I am using a scanner to input into a form. Unfortunately, my barcode contains 35 characters, including spaces, but I only need the first 7 characters.
    When we scan, our scanner is programmed to tab after the scan, so I am certain I need a procedure in the "Lost Focus" event. I am just not sure how to write that procedure.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You need to use the BeforeUpdate event of the control with something like:
    Me.ControlName = Left(Me.ControlName.Text,7)
    ...using your ControlName of course.

  3. #3
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    My Text box is [A1], so how would I word this? Thank you, too, by the way!!!! This is a HUGE help!

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try:
    Me.A1 = Left(Me.A1.Text,7)
    BTW, it is far more useful to name your controls something descriptive of their content or function. If not for you, then for the poor person that is asked to maintain the system a year later.

  5. #5
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    I am getting this error:
    The expression Before Update you entered as the event property setting produced the following error: Procedure declaration does not match the description of event or procedure having the same name

    In the after Update event, I also have

    Private Sub A1_AfterUpdate()
    If DCount("[Part Numaber]", "ILC Parts List", "[Part Numaber]='" & Me.ActiveControl & "'") > 0 Then
    Me.ActiveControl.BackColor = 8454143 'white
    Else
    Me.ActiveControl.BackColor = 16777215 'Yellow
    End If
    End Sub

    and I believe this is causing it to error out with the before update... Any thoughts?

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Change the BeforeUpdate event code to:
    Me.A1 = Left(Me.A1,7)
    ...and the AfterUpdate event should not affect this.

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    What is the DataType of the field to which the A1 control is bound?

  8. #8
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    It's Text. My data is alpha numeric.

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Good! That is as it should be.

  10. #10
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    Ugh... still getting the same error...

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Change the code to:
    MsgBox "[" & Left(Me.A1,7) & "]"
    ...and see what you get.

  12. #12
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    Ugh... still not it...
    It continues to give me the same error.

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try:
    MsgBox "[" & Me.A1 & "]"
    ...and display the entire string. Does that work?

  14. #14
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    Entering that, I do get a message box to pop up displaying the text that was input into the field

    I MUST HAVE DONE SOMETHING WRONG!!! THE FIRST ONE WORKED WHERE WE DECLARED 7 CHARACTERS!

  15. #15
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Does this mean this thread is Solved?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Multiple forms or embedded sub-forms
    By Juicejam in forum Forms
    Replies: 2
    Last Post: 08-23-2011, 07:31 AM
  2. Scanning table for duplicate entry from VBA
    By Buakaw in forum Programming
    Replies: 6
    Last Post: 03-08-2011, 07:29 PM
  3. Replies: 1
    Last Post: 01-04-2011, 05:04 AM
  4. Search forms and sub forms
    By FadingAPE in forum Forms
    Replies: 1
    Last Post: 12-15-2010, 01:59 PM
  5. Replies: 4
    Last Post: 04-01-2009, 08:49 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