inimicaljords
asked on
Access 2007 Adding to db through listbox
Here's what I got going on. I have an Access database with a table called TA. I am making a form to add records to this table. We have a scanner to scan serial numbers in to prevent typo's. I came up with a form to use to support the scanner. Here is what we want to add
All serial numbers in list box will have the same PO #
(txtPObulk) I have a text box asking what the PO is
(lstSystemTag) I have a list box that we put all the serial numbers in.
I want to add all the serials numbers with the PO that was entered into the table TA
I was able to come up with a loop to cycle through the list, but I can't figure out how to add them to the table.
I appreciate the help.
All serial numbers in list box will have the same PO #
(txtPObulk) I have a text box asking what the PO is
(lstSystemTag) I have a list box that we put all the serial numbers in.
I want to add all the serials numbers with the PO that was entered into the table TA
I was able to come up with a loop to cycle through the list, but I can't figure out how to add them to the table.
I appreciate the help.
Private Sub Command31_Click()
Dim j As Long
With Me.lstSystemTag
For j = 0 To .ListCount - 1
'MsgBox Me.lstSystemTag.Column(0, j), vbOKOnly, "Item number:" & j + 1
Next j
End With
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I got it to work with the following code. Had to change it a little but figured it out. Thanks!
CurrentDb.Execute "INSERT INTO TA (PO, SystemTag) VALUES ('" & Me.txtPObulk & "', '" & Me.lstSystemTag.Column(0, j) & "')"
ASKER
only 2 fields I am changing is PO and Systemtag, both are in a table called TA. There are other fields in this table but this is all I want to input.
I am wanting the PO to be the same for all systemtag that are in the list. So I only have to type the PO once and then I can scan the serial numbers into the list.