By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,509 Members | 1,686 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,509 IT Pros & Developers. It's quick & easy.

How to only allow KeyAsci 0 to 9 to be added to a field on a form

100+
P: 547
I use the code below to get data from a folder ("c:\RT\rfidlogs\") where rfid data is dumped into, by a RFID reader.

It works great as long as it is only ASci code "0-9" going into the "Racenumber", number type field.

i would like to build the following code into it, and i imagine it must be situated somewhere near where the xxx appears.

If text data or any other characters are received into this field, then it must be ignored and the setfocus should return it to the Racenumber field, in this "RacetimeT" table and "Sample2" form.

Please be so kind to assist.I am stuck as i cant get "if then" etc etc to make it work.

Code to use?
Expand|Select|Wrap|Line Numbers
  1. Select Case KeyAscii
  2.    Case Asc("0") To Asc("9")
  3.    Case Else
  4.     KeyAscii = 0
  5.    End Select
  6.  
This same code is used in the "on load" and "on timer" functions and works fine for number type data received

Expand|Select|Wrap|Line Numbers
  1.  On Error GoTo BillRedEnd
  2.     Const TheDirectory = "c:\RT\rfidlogs\"
  3.     Dim TheFile As String
  4.     Dim TheData As String
  5.     TheFile = Dir(TheDirectory & "*.OUT")
  6.     If TheFile <> "" Then
  7.     Open TheDirectory & TheFile For Input As #1
  8.     Line Input #1, TheData
  9. xxx
  10.     DoCmd.GoToRecord , , acNewRec
  11.     RaceNumber.SetFocus
  12.     RaceNumber.Text = TheData
  13.     RaceFinishTime.SetFocus
  14.     RaceFinishTime.Text = Format(Now(), "General Date")
  15.      Close #1
  16.      Kill TheDirectory & TheFile
  17.     End If
  18.     Exit Sub
  19.  
  20. BillRedEnd:
  21.     Debug.Print Err.Description
  22.    ' With Me
  23.    '![text1].SetFocus        
  24.    '![racenumber].SetFocus
  25.  End With
  26.     Close #1
Jul 25 '12 #1
Share this Question
Share on Google+
3 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,068
It would help if we saw samples of the RFID data and what you need the final data to look like....
Jul 25 '12 #2

100+
P: 547
Thx twinnyfo. Extract these files into a folder of your choice and refer to it from the code above.Both files must be extracted into the same folder.
When you extract it, Access read it immediately until a text character appears.That is when we must bypass it, to continue with the next correct number. thx for assisting
Attached Files
File Type: zip datetimeseq.zip (168 Bytes, 64 views)
File Type: zip Extract to C_RT_RFIDLogs.zip (134.1 KB, 53 views)
Jul 25 '12 #3

twinnyfo
Expert Mod 2.5K+
P: 3,068
neelsfer,

Still scratching my head..... Looking at the files you included, one was completley empty. For the other group of files, nearly every one of them had a four digit number "0052" with a few exceptions and a few strange characters.

It would help if I understood exactly what you are trying to do. It looks to me like you are simply adding the same number to a number field over and over again.... Is this on the OnOpen event of a form? Something else? i'm not following the purpose of this database, which might help me help you....
Jul 25 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.