Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display confirmation of input in data entry form 2

Status
Not open for further replies.

ramzoid

Technical User
Mar 4, 2005
12
0
0
US
Warning: question from a beginner

Context: A user with a barcoded ID card will use a simple data-entry form to "clock in" and "clock out" their arrival/departure by scanning their barcode.

Problem: I want to give the user visual confirmation of their input; specifically, the user will enter a number (by swiping their card), and I want the form (or subform) to display the number that was just scanned, along with the person's name pulled from a table that's linked by ID number. The ID number, date, and time of scanning are saved to a different table. The feedback is meant to confirm for the person clocking in that their card was read correctly, and the system recognizes them.

I had a very simple version of this database working OK without the visual feedback, but when I added a subform to provide the feedback, the main form no longer worked correctly. Through a series of tweakings, either the focus would not return to the input box, ready for the next number to be entered, or when I got the form to accept a new number, it would overwrite the previous record rather than create a new record. I'm a little confused about how to use one form for both input (clocking in the person) and output (displaying confirmation).

I don't know if this is just a matter of tweaking the form slightly (sending the focus to the right object and/or creating a new record when the right event occurs) or if I need to completely restucture the database. Should I even be using a subform, or can I do it all in the main form? If using a subform, I assume the data entry should be the main form, and the feedback should be the subform, but maybe this is backwards? Does it matter whether I base my subform on a query vs. a table?

I would be grateful for any tips!

Joe Ramsey
 
Hi Joe,
there is no right or wrong, but a subform is generally used when you have one main record and repeating data records associated with that main record, e.g. if you wanted to display all entry/exit records fro a user, that user's record would be on the main form and all entry/exit records would be in the sub-form and linked to the main form on the user-id. Hopefully that makes sense.

About your current problem, from what you have described a single form based on the table holding entry/exit records is all that is required. Set it up that when it is opened it will be on a new record and the focus in the barcode text box.
In the beforeupdate event of the text box, put in some code to check it is a valid user (I've used dummy field & table names):

Private Sub txtBarCode_BeforeUpdate(Cancel As Integer)
if DCount("*","tblEmployeeNumbers","EmpID=" & me!txtBarCode") =0 then
msgbox "This employee number is not valid or the barcode didn't scan properly etc"
Cancel=true 'This cancels the update
End Sub

Then in the after-update event of the barcode box, put in a function of your own to retrieve the user information:

sEmpName=dlookup("EmpName","tblEmployeeNumbers","EmpID=" & me!txtBarcode
Msgbox "Welcome " + sEmpName
Docmd.GoToRecord ,,acNewRec

Good luck.
 
Sarah,
This looks extremely promising! I'll have to wrestle with it a bit before I really understand the code, but it looks great. I did not know about the Msgbox function; that seems like a much better way to go than using a subform. I will see if I can get this working and report back.
Thanks so much!
-Joe
 
OK, so I think I understand Sarah's code, and it works like a charm (thanks again!), but I still have a problem.

I would like for the users to be able to check in & out using the barcode scanner only (no mouse, no keyboard), so the Msgbox doesn't quite do it, since users must click OK before the next user can scan their barcode.

(Users are high school students in a very large school checking in to the library; there are often long lines of kids waiting to sign in at the beginning of a period, so this solution is meant to expedite the sign-in process. As such, a single swipe of the card -- and no more -- is the goal.)

I'm now trying to use an unbound text box for the message (enabled: no; locked:yes). I tried putting the dlookup expression directly in the control source for the text box, and I also tried putting the welcome message into a string variable in the subroutine for the barcode input box, and then using this variable as the control source for the unbound box. These "almost" work (i.e. sometimes when returning to the form from the debugger, the message would correctly appear in the box), but mostly I get a "#Name?" error.

Am I on the right track at all? Do I need to define the string variable in a way that makes it "public"? (if so, how?) Do I need to do something to get the unbound text box to execute the dlookup at the right time? (what?) Should I be using something else besides the unbound text box?

Thanks!
 
how bout...

txtMessage = "Welcome " & dlookup("EmpName","tblEmployeeNumbers","EmpID=" & me!txtBarcode)

replace txtMessage with the name of your textbox.
 
So simple! I didn't know you could put content into a text box using the same syntax as storing a value in a variable.

Beautiful! It works perfectly.

Thanks!!!

Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top