Rfid form help (1 Viewer)

dale_j1992

Registered User.
Local time
Today, 17:32
Joined
Sep 23, 2016
Messages
26
Good evening i have an issue i just cant seem to resolve, i have a table where the primary key is a 10 digit number RFID number, and the second column is USERNAME linking the Unique RFID number with a username. i want to create a form where on open it is blank and the focus is set to the RFID number field, the user scans there card which inputs the number into the field automatically, i want the username to display automatically depending on the card scanned as per the Table, and maybe if possible a message box if the Card scanned is not on the system. i have the RFID scanner talking and working with ACCESS the only issue is this form. any help great or small is greatly appreciated. i am new too access. :banghead:
 

liddlem

Registered User.
Local time
Today, 17:32
Joined
May 16, 2003
Messages
339
I gather that you are new to Access, so this is probably the simplest way that I would do it.

Create a form that links to your RFID/User table.
Add a combo box to the form - when the wizard asks what you want to do with the combo box, select the option to find a record and follow the prompts.

Now if you look in the 'After update' event, you should see how Access created a macro to find the record.
I Know that this is NOT exactly what you want, but try searching for an RFID. It should just work if you have applied the correct info.

So now, add another text box and call it something like 'search RFID'.
Copy all the details of the event and the source parameters from the COMBO box to the text box. (You may want to put the macro in the 'On change' event, rather than the 'After Update' event?)

Use your scanner to populate the text field and then run the code.
Make sure the text box is working properly, then delete the combo box.

Hope this helps
 

sneuberg

AWF VIP
Local time
Today, 09:32
Joined
Oct 17, 2014
Messages
3,506
I've attached a simple database that can be use as a vehicle for discussing your project. If you open the database, open the form, and type A123456789 a scary name will be displayed in the Username textbox. This happens because of the following code in the On Change event that I will discuss.

Code:
Option Compare Database
Option Explicit
Public CharCount As Long

Private Sub txtRFID_Change()

CharCount = CharCount + 1
Debug.Print CharCount
If CharCount < 10 Then
    Exit Sub
End If
CharCount = 0
Me.txtUserName = DLookup("[USERNAME]", "[Users]", "[RFIDNumber] = '" & Me.txtRFID.Text & "'")


End Sub

First the reason why I'm using the On Change event is that's the only event I know of that will fire on the input of text into a textbox without any other action. If your scanner has a button that can transmit a new line and you are willing to use it then this could be done differently.

I declared a global variable (CharCount) to keep track of the number of character that have been entered. This needs to be global so that the count is retained between the firings of the on change event. As long as the count is less than nine the code does nothing but increment the count. When 10 is reach the DLookup looks up the user name that corresponds with the RFID number and places it in the user name text box. You could skip the counting and just attempt a lookup for each input character but if the table has a lot of records this could result in a jerky response.

This obvious needs work and some decisions on how to do this. Let's say the scanner scans less than ten digits. What should happen? Do you want a button for the user to click to reset and start over or do you want a timer that automatically resets everything?

What do you want to happen (other than display the user name) when the RFID number is entered correctly.

What do you want to happen if the RFID number is not in the table?
 

Attachments

  • RFIDNumberScan.accdb
    416 KB · Views: 66

Users who are viewing this thread

Top Bottom