Results 1 to 7 of 7
  1. #1
    gregu710 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Frederick, CO (near Longmont and Boulder)
    Posts
    40

    Protecting a Text Box that has a Date Picker function

    Hi, i've got a Form which has a Text Box on it with a Date Picker Function. The operator of the database clicks on the Text Box in the form, the Date Picker Calendar opens, and he selects the date needed. This triggers a VBA function called JulianDate which converts the calendar date selected in the Text Box to a "Ordinal" or "Julian" date for my Database. HOWEVER, the operator is typically working with a handheld barcode scanner, and I have seen times where they are not paying close attention to what they are doing and accidentally scan a barcode while the cursor is in the Text Box where they are supposed to select the date. This causes the VBA window to open and his barcode data is dumped right into the middle of my script. I can fix this manually, but this causes confusion for the operator and is a hassle. Is there any way to protect that Text Box so that the only data that can be entered is by the Date Picker calendar, and not by scanning or manual data entry, or that if this does happen, the VBA window doesn't open and allow the scanned data to be accidentally inserted into my Code? Thanks for any ideas!

  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
    Hmm...why do you think the VBA window opens?

  3. #3
    gregu710 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Frederick, CO (near Longmont and Boulder)
    Posts
    40
    RuralGuy, as soon as anything other than the date code is entered in the Text box, it opens the Visual Basic window. My bar code scanner has a carriage return programmed into for proper functioning, and so after a barcode is accidentally scanned, Access brings up a warning Window for Visual Basic with the message "Run-time error '2110', Microsoft Access can't move the focus to the control Text2 (the text box which is tied to the JulianDate VB code). I suspect that since "Debug" is the default button on the VB warning window, that the carriage return from the scanner causes that to be activated, thus causing the Visual Basic Code window to open. One option, IF it were possible, would be to have the default button on the VB warning window be "End" instead of "Debug", since this would just cause the focus to shift back to the TextBox and the operator could continue on as if there was no problem. By the way, greetings from 3400' below you...

  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
    How do you have your Error Trapping set? [any code module]>Tools>Options...>General Tab on the middle right

  5. #5
    gregu710 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Frederick, CO (near Longmont and Boulder)
    Posts
    40
    Quote Originally Posted by RuralGuy View Post
    How do you have your Error Trapping set? [any code module]>Tools>Options...>General Tab on the middle right
    RuralGuy, I tried all three modes, but not fixing the problem. My code is set up right now to activate my VB Code on "On Change". I changed that to "Lost Focus" since I have a List Box that the operator must use after the Date Code, and this seems to fix the problem. The operator now gets a normal warning message that tells him he doesn't have the right kind of data in the Date Text Box, and keeps him away from my VB Code. Think that will do the trick. Thanks for the tip about Error Trapping though and for taking a look at it.

  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
    You get an OnChange event for *each* character entered in the control. A scan should successfully drive it nuts. Validation is usually accomplished in the BeforeUpdate event of a control where you can cancel any update and even UnDo any damage done.

  7. #7
    gregu710 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Frederick, CO (near Longmont and Boulder)
    Posts
    40
    thanks, I'll give that a try....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Date Picker?
    By gazzieh in forum Forms
    Replies: 9
    Last Post: 02-09-2013, 09:35 AM
  2. Date Picker doesn't appear
    By revnice in forum Access
    Replies: 9
    Last Post: 01-09-2012, 08:36 AM
  3. Date Picker
    By kelly in forum Database Design
    Replies: 3
    Last Post: 09-15-2011, 12:42 PM
  4. Date Picker
    By otisdaddy in forum Database Design
    Replies: 2
    Last Post: 07-01-2011, 12:30 PM
  5. Date picker
    By BI4K12 in forum Access
    Replies: 1
    Last Post: 06-09-2010, 11:11 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