We help IT Professionals succeed at work.

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

Tyler Bennett
on
53 Views
Last Modified: 2017-08-23
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

Example:
Currently:
Scanner - aaaddd
stored
uploaded to textbox [aaaddd]
saved
table gets updated to include [aaaddd]

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

**The scanner stores them as new rows ... ie:
[a1
 a2
 a3
 a4]
Comment
Watch Question

John TsioumprisIT Supervisor
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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...
CERTIFIED EXPERT

Commented:
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.addnew
   rst!YourField = trim(r(i))
   rst.update
next i
rst.close
end sub

Open in new window

Author

Commented:
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

Author

Commented:
als315

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.AddNew
    rst!DataIN = Trim(r(i))
    rst.Update
Next i
rst.Close


Exit_Command16_Click:
    Exit Sub

Err_Command16_Click:
    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?
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
I think question was answered, but author forget to close it

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions