I get it! In the form properties, for the On Error event, I put the MsgBox DataErr line, and this gives me the error number. Then I add the other code with the error number plugged in, and it kills that particular error message. Excellent! It works. (I still don't know why I was getting the...
As far as I can tell, there is no actual "validation rule" per se, neither on the text box on the form, nor on the underlying fields in the table. I have been assuming that the validation error comes from the code for the BeforeUpdate event; I don't really know, though, if Access considers this...
OK. I think you'll see there's not any real difference in format between passing and failing barcodes; it's just a matter of whether that particular number is in the database.
Pass: 9969, 97300, 129310
Fail: 9970, 97301, 129410
"The value in the field or record violates the validation rule...
So, I'm thinking through this a little more... The "If" statement with the Dcount function appears to be working OK, because when the barcode entered does exist in the table "barcode name", the sub ends as it should, and when the entered barcode does not match, I do in fact get the desired...
AceMan,
A very reasonable guess (thanks!), but it doesn't appear that that was the problem. I got a data type mismatch when I tried it.
Thanks though! Any other hunches?
Cheers!
I have a data-entry form with one bound text field to receive a number from a barcode scanner. The BeforeUpdate event for this field contains code to verify that the ID number scanned is valid:
Private Sub barcode_BeforeUpdate(Cancel As Integer)
If DCount("*", "barcode name", "barcode=" &...
Thanks! The suggestion you posted to the related thread, of just setting the name of the ubound box equal to the dlookup expression (in the sub for the data-entry box) works perfectly!
Thanks for addressing all the sub-questions!
Joe
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
I am trying to use an unbound text box to display a message based on the contents of a data-entry text box. In the sub associated with the data-entry box, the message text is stored in a string variable, sMessage. I tried simply putting =[sMessage] in the control source for the unbound box...
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...
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...
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...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.