Heeeellllllpp>

ktariske

Registered User.
Local time
Today, 07:16
Joined
Jun 12, 2002
Messages
31
Emergency... we have a form that we use to enter in a 4 digit number from a barcode scanner. The bar codes on our inventory is returning a capital O instead of the number zero. Is there any way to intercept the carrage return and check for a capital O and insert a number 0 in it's place???? Helppppp today. ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
 
Ok here is some sample code, mostly provided by the MS knowledge base -
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q138774 (thanks to Jack Cowley for pointing it out in another post)

cmdReturn is the button you press to process the entry, and txtBarCode is the text field where the barcode appears (so you will need to replace those names). Everything else can stay as is.

Private Sub cmdReturn_Click()
Dim strChar As String, strHoldString As String, strBarCode As String
Dim i As Integer

txtBarCode.SetFocus
strBarCode = txtBarCode.Text

If strBarCode Like "*O*" Then
For i = 1 To 4
strChar = Mid$(strBarCode, i, 1)
Select Case strChar
Case "O"
strHoldString = strHoldString & "0"
Case Else
strHoldString = strHoldString & strChar
End Select
Next i
txtBarCode.Text = strHoldString
End If

End Sub

Good luck!

-Sean
 
Also - you can use the lost_focus instead of using the button which would be after all other info is inputted (that's probably what you want).

So instead of: "Private Sub cmdReturn_Click() "
put: "Private Sub txtBarCode_LostFocus()"
and remove the .setfocus line.

I'll email a demo to you to help.

-Sean
 
Returning different value to table from form.

Returning different value to table from form.

By using the following code, we can get the code changed by watching the code monitor, but then we can't pass the value to the approperate table.

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim BadStr As String
Dim GoodStr As Integer

BadStr = id.Text
GoodStr = Replace(BadStr, "O", "0")
id.Value = GoodStr
End Sub

Everything works until it get to the line "id.value = Goodstr" whose value at that point is an integer with the "O" changed to a zero. Problem is, the line errors with Run-time error '2115' The macro of funtion set to the BeforeUpdate or Validation Rule property for this field is preventing from saving the data in the field.
 
quick thought before I have to go...

Try:
id.Value = Int(GoodStr)
or
id.Text = GoodStr

(could be data type conflict)

-Sean
 

Users who are viewing this thread

Back
Top Bottom