Re: Values from multiselect listbox being written to a table
- From: "Rino" <davorins@xxxxxxxxx>
- Date: 9 Aug 2006 15:00:32 -0700
try to play with this code. It works for me.
------------------------
Private Sub cmdOK2_Click()
If IsNull(Summary) Then
MsgBox "You must populate summary field."
Exit Sub
Else
'DoCmd.RunSQL ("INSERT INTO dbo_QuoteMain(Quote_ID, Org_ID, Per_ID,
Quote_Num, Summary, FirstName, LastName, Address1, Address2, Address3,
City, State, Zip, Country, PriPhone, FaxPhone, EmailAddress,
ExpireDate, ShipState, ShipZip, AddDate, SubTotal, GrandTotal) VALUES
('" & Me![txtQuoteID] & "' , '" & Me![Org_ID] & "' , '" & Me![Per_ID] &
"' , '" & Me![txtQuoteNo] & "' , '" & Me![txtSummary] & "' , '" &
Me![FirstName] & "' , '" & Me![LastName] & "' , '" & Me![Address1] & "'
, '" & Me![Address2] & "' , '" & Me![Address3] & "' , '" & Me![City] &
"' , '" & Me![State] & "' , '" & Me![Zip] & "' , '" & Me![Country] & "'
, '" & Me![PriPhone] & "' , '" & Me![FaxPhone] & "' , '" &
Me![EmailAddress] & "' , '" & Me![ExpireDate] & "' , '" &
Me![ShipState] & "' , '" & Me![ShipZip] & "' , '" & Me![AddDate] & "' ,
'" & Me![txtTotal2] & "' , '" & Me![txtTotal] & "')")
GrandTotal = txtTotal.Value
Dim db As DAO.Database
Dim strSQLBase As String
Dim strSql As String
Dim i As Long
strSQLBase = _
"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] & "' , "
Set db = CurrentDb
With Me!lstResults2
For i = Abs(.ColumnHeads) To (.ListCount - 1)
strSql = strSQLBase & _
"'" & .Column(0, i) & "' , " & _
"'" & .Column(1, i) & "' , " & _
"'" & .Column(2, i) & "' , " & _
"'" & .Column(3, i) & "')"
db.Execute strSql, dbFailOnError
Next i
End With
End If
DoCmd.Close
Exit_cmdClose_Click:
Exit Sub
End Sub
--------------------------
-Rino
.
- References:
- Re: Values from multiselect listbox being written to a table
- From: jahoobob via AccessMonster.com
- Re: Values from multiselect listbox being written to a table
- Prev by Date: Re: Saving Back-End Data As mdf
- Next by Date: Re: Saving Back-End Data As mdf
- Previous by thread: Re: Values from multiselect listbox being written to a table
- Index(es):
Loading