1,105,290 Community Members

Need a little tweak to code please help Delete funtion

Member Avatar
Farhan_B
Junior Poster in Training
66 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I sence victory been battling the this code for 2 days now.

the code i have generated is

strsql = "delete from cg_security_user_right where  user_id= " & TextBox1.Text & " role_id=" & TextBox2.Text & ""

it comes up with this error

Syntax error (missing operator) in query expression 'user_id= 2 role_id=1'.

how do i get past this please

Thank yo so much

Member Avatar
Mitja Bonca
Posting Maven
2,561 posts since May 2009
Reputation Points: 557 [?]
Q&As Helped to Solve: 489 [?]
Skill Endorsements: 21 [?]
 
1
 

try:

strsql = "delete from cg_security_user_right where user_id = '" & TextBox1.Text & "' role_id = '" & TextBox2.Text & "'"
Member Avatar
Farhan_B
Junior Poster in Training
66 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

no its still coming with the same error :{

Member Avatar
Farhan_B
Junior Poster in Training
66 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

im seriously scratching my head i cannot think of the thing it can b any suggestions

Member Avatar
Reverend Jim
Noli mentula
5,394 posts since Aug 2010
Reputation Points: 746 [?]
Q&As Helped to Solve: 643 [?]
Skill Endorsements: 51 [?]
Moderator
Featured
 
0
 

Right after the line where you create the query, please add the following

MsgBox(strsql)

and post the results for us to see.

Member Avatar
Phasma
Junior Poster in Training
81 posts since Nov 2008
Reputation Points: 11 [?]
Q&As Helped to Solve: 21 [?]
Skill Endorsements: 3 [?]
 
0
 

This is a simple Delete query created in Access 2007. I do not believe you need the extra double quote you had in your original post or the single quotes I saw in another unless your user_id and role_id are strings and not integers.

Dim sql As String = "DELETE * FROM [Copy Of tbl_Inventory]" & _
                        "WHERE ((([Copy Of tbl_Inventory].Item_ID)=181));"
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: