Link to home
Start Free TrialLog in
Avatar of Tyler Bennett
Tyler Bennett

asked on

Trying to use multiple inputs of the same type into a form to update the relevant field in a table

I hope it's a basic prolem.... we're creating an inventory system for our plant. The scanner we have can scan either a single dataset then store it and then transfer it (I have a database that works for that.... the update simply sends the stored data to the textbox which is linked to my table)....

My problem:
The scanner can also store multiple inputs and hold them (say 10 at a time) so that it's more efficient.... however I don't know how to adapt my form to take in multiple datasets in the same 'textbox' or some variation of and then update the table with all relevent records

Scanner - aaaddd
uploaded to textbox [aaaddd]
table gets updated to include [aaaddd]

Scanner - a1 a2 a3 a4 a5 a6
upload to............ single text box fails
table gets updated with a1 a2 a3 a4 a5 a6

**The scanner stores them as new rows ... ie:
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

I am not sure i understood your problem...i guess you want to "exploit" the capability of your scanner's memory to do rapid scans (x10) and do an update /insert in the  bulk....probably your scanner can append a special character at the end of each scan and send one big string delimited...You split the string (split command) and you do the necessary work afterwards...
You can use code to split text from scanner into records in your table
use split function with code like this:
sub split_scanner(txtScanned as string)
Dim r() As String, i as integer
Dim rst as recordset
rst = CurrentDb.Openrecordset("yourtable")
r = Split(txtScanned, vbCrLf)
for i = 0 to ubound(r)
   rst!YourField = trim(r(i))
next i
end sub

Open in new window

Avatar of Tyler Bennett
Tyler Bennett


I appreciate the help and will try to use your code als315....

To further summarize:
scanner scans 1 dataset which is then transferred to my form's textbox which can then be saved to my table...

My Issue:
With multiple scans, the scanner uses a delimiter (can be either a return or a tab delimiter)..... so now the scanner will transfer all the data to the single textbox [scan1  scan2  scan3  scan4] , with each scan being seperated by the delimiter.

Is there a way to code my save button so it essentially 'splits my multiple scans into individual inputs to then save as each individual scan'
i.e. Without code to handle the delimiter if I were to save the input then my input for the single record on the table would show : scan1  scan2  scan3  scan4

Whereas I need it to show
record1  scan1
record2 scan2
record3 scan3
record4 scan4

I hope this clears things up

Where do I implement that code?

I tried to throw that code in my save button code to result in:
Private Sub Command16_Click()
On Error GoTo Err_Command16_Click

Sub split_scanner(Text17 As String)
Dim r() As String, i As Integer
Dim rst As Recordset
rst = CurrentDb.OpenRecordset("Main_Database_")
r = Split(Text17)

For i = 0 To UBound(r)
    rst!DataIN = Trim(r(i))
Next i

    Exit Sub

    MsgBox Err.Description
    Resume Exit_Command16_Click

End Sub

Open in new window

Now I get "Unexpected End Sub" while highlighting the Private Sub first line.... any ideas?
Avatar of als315
Flag of Russian Federation image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think question was answered, but author forget to close it