A
Aric Green
I have a form in my database that contains a listbox of card numbers. This
listbox is a multiselect listbox. I also have a combobox with employee
names. I want to choose an employee name and then select multiple card
numbers and when i click a button I want the cards to be assigned to the
employee in the table. The table contains a field for the employee name.
The code I have so far is as follows
code
------------------------------------------------------------------------------------------------
Private Sub ASSIGN_USER_TO_CARDS_Click()
Dim db As Database
Dim rec As Recordset
Dim varSelected As Variant
Dim strSQL As String
Set db = CurrentDb()
Set rec = db.OpenRecordset("CARDSTOCK ACCOUNTABILITY")
For Each varSelected In Me!List9.ItemsSelected
strSQL = ""
strSQL = strSQL & " Update CARDSTOCK_ACCOUNTABILITY SET
CLERK_CARD_ISSUED_TO = " & Me.cmb11
strSQL = strSQL & " WHERE CLERK_CARD_ISSUED_TO = " &
Me!List9.ItemData(varSelected)
CurrentDb.Execute strSQL
Next varSelected
Set db = Nothing ' Clear db...
MsgBox ("This data is now in your table..")
End Sub
------------------------------------------------------------------------------------------------
When I push the button it gives me an error the following error.
Run-time error '3075':
Syntax error (missing operator) in query expression 'USERS NAME IS HERE'.
When I click debug the line
CurrentDB.Execute strSQL
is highlighted.
I have tryed DoCmd.RunSQL strSQL and get the same thing. I am not sure what
I have done wrong. I am fairly new to writing vb code.
Thanks.
listbox is a multiselect listbox. I also have a combobox with employee
names. I want to choose an employee name and then select multiple card
numbers and when i click a button I want the cards to be assigned to the
employee in the table. The table contains a field for the employee name.
The code I have so far is as follows
code
------------------------------------------------------------------------------------------------
Private Sub ASSIGN_USER_TO_CARDS_Click()
Dim db As Database
Dim rec As Recordset
Dim varSelected As Variant
Dim strSQL As String
Set db = CurrentDb()
Set rec = db.OpenRecordset("CARDSTOCK ACCOUNTABILITY")
For Each varSelected In Me!List9.ItemsSelected
strSQL = ""
strSQL = strSQL & " Update CARDSTOCK_ACCOUNTABILITY SET
CLERK_CARD_ISSUED_TO = " & Me.cmb11
strSQL = strSQL & " WHERE CLERK_CARD_ISSUED_TO = " &
Me!List9.ItemData(varSelected)
CurrentDb.Execute strSQL
Next varSelected
Set db = Nothing ' Clear db...
MsgBox ("This data is now in your table..")
End Sub
------------------------------------------------------------------------------------------------
When I push the button it gives me an error the following error.
Run-time error '3075':
Syntax error (missing operator) in query expression 'USERS NAME IS HERE'.
When I click debug the line
CurrentDB.Execute strSQL
is highlighted.
I have tryed DoCmd.RunSQL strSQL and get the same thing. I am not sure what
I have done wrong. I am fairly new to writing vb code.
Thanks.