|
-
Oct 24th, 2006, 06:02 PM
#1
Thread Starter
Junior Member
strsql = "Delete..."
Hi,
My code is not deleting the selected record as I wanted to. I think there is something wrong with the line of code, DoCmd.RunSQL ("DELETE FROM UserRole WHERE WindowsUser = " & strDeleteUser)
Any advice will be greatly appreciated!
Private Sub cmdDeleteUser_Click()
Dim Check As Integer
Dim strDeleteUser As String
strDeleteUser = Me.txtFillWindowsUser.Value
Check = MsgBox("Are you sure that you want to delete this user?", vbYesNoCancel)
If Check = vbCancel Then
Cancel = True
ElseIf Check = vbYes Then
DoCmd.RunSQL ("DELETE FROM UserRole WHERE WindowsUser = " & strDeleteUser)
DoCmd.Requery
DoCmd.OpenForm "frmAdmin"
ElseIf Check = vbNo Then
No = True
End If
End Sub
-
Oct 24th, 2006, 06:48 PM
#2
Frenzied Member
Re: strsql = "Delete..."
DoCmd.RunSQL ("DELETE FROM UserRole WHERE WindowsUser = '" & strDeleteUser & "'")
Note the single quote after the equal sign, and the double, single, double quote after strDeleteUser. I also tend to use DELETE * in Access, not sure it's mandatory, though. Some dbs don't allow it.
Tengo mas preguntas que contestas
-
Oct 24th, 2006, 06:53 PM
#3
Thread Starter
Junior Member
Re: strsql = "Delete..."
Thank you soo much!! It worked
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|