Page 3 of 3 FirstFirst 123
Results 31 to 35 of 35
  1. #31
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,745
    So I created a form (frmEmployeesWithBarcode) using the Form wizard. Made it a single record form.

    Remember My test table was tblEmployees, I added a MIDTestNumber field to represent your desiredCode format.
    I then added a line to the afterUpdate evnt ontxtIncomingBarcode. Here is the revised code behind the form.

    You will have to adjust the openForm command with your Form's name and your field name (to replace my MidTestNumber) but it should work. I adjusted what we have built because, if you scan a card, you have to get the barcode, then the DesiredCode in order to find the correct record in Table1.

    Private Sub txtIncomingBarcode_AfterUpdate()
    On Error GoTo txtIncomingBarcode_AfterUpdate_Error



    Me.txtDesiredCode = Mid([txtIncomingBarcode], 2, 6)
    Debug.Print Me.txtDesiredCode & " at " & Now()
    DoCmd.OpenForm "frmEmployeesWithBarcode", , , "MidTestNumber ='" & Me.txtDesiredCode & "'"
    On Error GoTo 0
    Exit Sub

    txtIncomingBarcode_AfterUpdate_Error:

    MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure txtIncomingBarcode_AfterUpdate of VBA Document Form_Form13"
    End Sub

    Private Sub txtIncomingBarcode_BeforeUpdate(Cancel As Integer)
    'This is where the Original Barcode gets placed when the employee's
    'card is scanned.

    On Error GoTo txtIncomingBarcode_BeforeUpdate_Error

    If Me.txtIncomingBarcode = vbNullString Then
    MsgBox "There must be a barcode in txtIncomingBarcode"
    End If

    On Error GoTo 0
    Exit Sub

    txtIncomingBarcode_BeforeUpdate_Error:

    MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure txtIncomingBarcode_BeforeUpdate of VBA Document Form_Form13"
    End Sub
    SO now, you scan the persons card, it puts the barcode into the IncomingCode textbox; You move out of that textbox and it puts the desiredCode in txtDesiredCode,
    and Opens the form with the correct person's info in that form.

  2. #32
    brandonze is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Mar 2011
    Posts
    49
    The DesiredCode is already in the Table, Under the field of MyCode.

    The goal is to have the form open already, the cursor would be in the txtIncomingBarcode txet Box. The user would then scan the employees card, and then the record would be pukked up on the form.

    in the beginging the form is open with my defualt values displalying in the boxes.

    I am trying to make this as automated as possible.

  3. #33
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,745
    Why were you asking about the mid function if the desiredCode is in the Table?

    If the card has to be scanned to identify the person, when does the scanned barcode go? It has to be some where if you're going to parse it for the 6 positions you need.

    It seems you are now saying:

    I have a table of employee information. Each employee is uniquely identified by a DesiredCode. Each employee has a badge/card?? that contains several digits. We scan the card and get this long set of digits, BUT we only care about positions 2-7 because that's the same code we stored in the Table to identify the employee.

    We does the card contain all the digits, or why does the desiredCode only have a subset of the digits?

    Did you try adjusting the form as mentioned in my post 31?

  4. #34
    brandonze is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Mar 2011
    Posts
    49
    I think we just were writing at the same time. It worked perfectly. I could not have done it without your help. Thank you much.

    I will be adapting the to the large DB tomorrow!!!

  5. #35
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,745
    I'm glad you have it working. Sometimes it takes going thru this process of talking to someone who knows nothing of your environment, but trying to explain/describe a process or procedure. It's a learning in communications if nothing else.

    Anyway, good luck with your project, it could still be refined. Just cause it puts up the correct form doesn't necessarily mean it's good code, or an efficient procedure. It seems to work -- great.

    If your table has lots of different "things" in it, you might want to read the first 3 topics at this site.

    http://www.rogersaccesslibrary.com/forum/topic238.html
    Good luck.

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Apply Filter based on unbound date boxes
    By anoob in forum Access
    Replies: 3
    Last Post: 01-21-2011, 05:26 PM
  2. Replies: 5
    Last Post: 10-06-2010, 07:28 PM
  3. Apply filter command
    By miziri in forum Forms
    Replies: 6
    Last Post: 01-21-2010, 02:22 AM
  4. Using a form to apply a condition to a Query
    By JeepWidow in forum Forms
    Replies: 0
    Last Post: 12-22-2008, 10:29 AM
  5. Apply check at record level
    By wasim_sono in forum Programming
    Replies: 1
    Last Post: 04-19-2007, 07:48 AM

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