ListBox Error

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

ListBox Error

Post by burrina »

I have a ListBox that is set to Simple. I want to insert the Reports selected into my table and set the permissions for that user.
My error is this Line Argument not optional

Code: Select all

Dim strSQL As String

DoCmd.SetWarnings False
strSQL = "INSERT INTO tblReportList (userID) " & _
      "VALUES (" & Me.byUserID & ", " & Me.rptlists.ItemsSelected & ")"
     Call MsgBox("All Users Report Access to Selected Report(s) is Set to Allow.", vbExclamation, "Report Access")
DoCmd.SetWarnings True

CData
3StarLounger
Posts: 287
Joined: 24 Dec 2015, 16:41

Re: ListBox Error

Post by CData »

INSERT INTO Table.Field

there can only be 1 value if there is only 1 field ... the comma looks like there are 2 values

the sql statement needs to be executed

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: ListBox Error

Post by burrina »

OK, got it figured out.
Thanks,

User avatar
HansV
Administrator
Posts: 74448
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: ListBox Error

Post by HansV »

Into which field or fields do you want to append data?
Regards,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: ListBox Error

Post by burrina »

Sorry for the late reply. I was making it way too complicated as usual.
I gave up on the SQL since I could not get it to work but instead used queries and bound the table and other stuff.
Will post back after testing if this approach does not work.