PDA

View Full Version : Auto Data Display by Scanning. Please help



Oyeski
05-23-2016, 04:15 AM
I am new to vb. I am currently running a project and I have this challenge.

My data template was designed to capture new asset using barcode label. By clicking new, I can capture details of any assets after application of barcode label. This is working perfectly as planned.

Now, I want to use same template to carry out Audit of same asset captured. My intention is to scan the barcode label into the barcode text box, then it should bring out the asset details if it is within the database (i.e, if it is found on the datasheet). But if not, it should come up with a message that the item does not exist, whether I want to create it with Yes or No message.

If I click Yes, it should just activate the “New” button for me automatically to capture the new asset details as required otherwise, it should not change.

I tried to rearrange and modify the Barcode field code(xtBarcode) but not working. Can someone kindly assist in correcting where I missed it. I have also attached the whole file used for the project

See my code below


Private Sub txtBarcode_Change()
'set min barcode char length
'change as required
'find and show barcode data after scan

Dim FoundCell As Range
Set FoundCell = wsDatabase.Columns(2).Find(Me.TxtBarcode.Text, lookat:=xlWhole, LookIn:=xlValues)
If Not FoundCell Is Nothing Then
r = FoundCell.Row - 1
Else
r = r - 1
MsgBox "Barcode: " & Me.TxtBarcode.Text & Chr(10) & "Record Not Found", 48, "Not Found"
Me.TxtBarcode.SetFocus
End If
Me.cmdAddUpdate.Enabled = Len(Me.TxtBarcode) > 8
Me.cmdFind.Enabled = Me.cmdAddUpdate.Enabled

End Sub