R
robboll
I am trying to append multiple selected values from a listbox to a
table. Property set to Multi Select (extended).
Access 2007
Form: Main
ListBox Control: List3
Test values: One, Two, Three . . .
Destination Table: Selections
Destination Field: Selected
Control: Command Button.
Syntax:
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub Command5_Click()
On Error GoTo Err_Command5_Click
Dim strSQL As String
strSQL = "INSERT INTO selections ( selected ) VALUES (" & Me!
List3.Column(1) & ");"
CurrentDb.Execute strSQL, dbFailOnError
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click
End Sub
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running debug the value of strSQL:
strSQL = "INSERT INTO selections ( selected ) VALUES (TEN);"
Generates error: Too few parameters. Expected 1.
Any suggestions appreciated!
RBollinger
table. Property set to Multi Select (extended).
Access 2007
Form: Main
ListBox Control: List3
Test values: One, Two, Three . . .
Destination Table: Selections
Destination Field: Selected
Control: Command Button.
Syntax:
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub Command5_Click()
On Error GoTo Err_Command5_Click
Dim strSQL As String
strSQL = "INSERT INTO selections ( selected ) VALUES (" & Me!
List3.Column(1) & ");"
CurrentDb.Execute strSQL, dbFailOnError
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click
End Sub
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running debug the value of strSQL:
strSQL = "INSERT INTO selections ( selected ) VALUES (TEN);"
Generates error: Too few parameters. Expected 1.
Any suggestions appreciated!
RBollinger