R
Rino
Greetings,
This is my first post and I hope it'll be the lucky one since I've been
hurting my head with the following situation for a while now.
I need to be able to populate a table from all of the items located in
the listbox.
To be more precise this is the procces user needs to perform.
1. from listbox1 user selects the item(row) that populates 3 textboxes.
2. on the command button click, data from those three textboxes goes to
another listbox2 and than it populates it
However, user can go back and repeat the step 1 and then listbox2 will
be populated with another item, so in other words there are now two
rows of data in the listbox2.
What I need here is a function that will allow the user to be able to
hit the command button which will than grab all of those values from
the listbox2 (x number of rows) and populate the table.
Example:
say ID=123
ListBox2
row1: 1, cd234 , this is blalala, $111
row2: 3, fds12, blalbdglfsfgkd, $222
Table after being populated
row1: 123, cd234 , this is blalala, $111
row2: 123, fds12, blalbdglfsfgkd, $222
With big please with whip cream and cherry on the top how can I achieve
this proccess.
I have the code here that only inserts the first record in the table
and can not figure it out how to enter the second, third, etc.
Dim Quan As String
Dim PartNum As String
Dim Description As String
Dim ListEach As String
Dim frm As ListBox, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set frm = Me.lstResults2
'Set ctl = frm!QuoteDetail
Set ctl = frm
DoCmd.SetWarnings False
For Each varItem In ctl.ItemsSelected
strSQL = "INSERT INTO dbo_QuoteItem (QuoteItem_ID, Quote_ID,
Per_ID, Org_ID, Quan, PartNum, Description, ListEach) VALUES ('" &
Me![txtQuoteItemID] & "' , '" & Me![txtQuoteID] & "' , '" & Me![Org_ID]
& "' , '" & Me![Per_ID] & "' , '" & Me.lstResults2.Column(0) & "' , '"
& Me.lstResults2.Column(1) & "' , '" & Me.lstResults2.Column(2) & "' ,
'" & Me.lstResults2.Column(3) & "')"
Debug.Print strSQL
DoCmd.RunSQL strSQL
Next varItem
DoCmd.SetWarnings True
Please help!
Thanks in advance
-Rino
This is my first post and I hope it'll be the lucky one since I've been
hurting my head with the following situation for a while now.
I need to be able to populate a table from all of the items located in
the listbox.
To be more precise this is the procces user needs to perform.
1. from listbox1 user selects the item(row) that populates 3 textboxes.
2. on the command button click, data from those three textboxes goes to
another listbox2 and than it populates it
However, user can go back and repeat the step 1 and then listbox2 will
be populated with another item, so in other words there are now two
rows of data in the listbox2.
What I need here is a function that will allow the user to be able to
hit the command button which will than grab all of those values from
the listbox2 (x number of rows) and populate the table.
Example:
say ID=123
ListBox2
row1: 1, cd234 , this is blalala, $111
row2: 3, fds12, blalbdglfsfgkd, $222
Table after being populated
row1: 123, cd234 , this is blalala, $111
row2: 123, fds12, blalbdglfsfgkd, $222
With big please with whip cream and cherry on the top how can I achieve
this proccess.
I have the code here that only inserts the first record in the table
and can not figure it out how to enter the second, third, etc.
Dim Quan As String
Dim PartNum As String
Dim Description As String
Dim ListEach As String
Dim frm As ListBox, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set frm = Me.lstResults2
'Set ctl = frm!QuoteDetail
Set ctl = frm
DoCmd.SetWarnings False
For Each varItem In ctl.ItemsSelected
strSQL = "INSERT INTO dbo_QuoteItem (QuoteItem_ID, Quote_ID,
Per_ID, Org_ID, Quan, PartNum, Description, ListEach) VALUES ('" &
Me![txtQuoteItemID] & "' , '" & Me![txtQuoteID] & "' , '" & Me![Org_ID]
& "' , '" & Me![Per_ID] & "' , '" & Me.lstResults2.Column(0) & "' , '"
& Me.lstResults2.Column(1) & "' , '" & Me.lstResults2.Column(2) & "' ,
'" & Me.lstResults2.Column(3) & "')"
Debug.Print strSQL
DoCmd.RunSQL strSQL
Next varItem
DoCmd.SetWarnings True
Please help!
Thanks in advance
-Rino