• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 88
  • Last Modified:

Getting warning: You are about to delete 1 row(s)

I'm creating a Logon form for my Access 2013 app and when I enter my password, I get the "you are about to delete... ' warning.  The sysUser is a one record table and sysUsers is a linked, one record table.  Here's my code:

Private Sub Pswrd_AfterUpdate()
   
    If Me.Pswrd = DLookup("Password", "sysCareUsers", "ContactID = " & Me.UserName.Column(0)) Then
        gblUserGroup = DLookup("SecurityLevel", "sysCareUsers", "ContactID = " & Me.UserName.Column(0))
        'Save info into sysUser and sysUsers tables
        DoCmd.SetWarnings False
        DoCmd.RunSQL ("UPDATE sysUser SET UserID = " & gblUserID)
        DoCmd.RunSQL ("UPDATE sysUsers SET UserID = " & gblUserID)
        DoCmd.RunSQL ("UPDATE sysUser SET UserGroup = " & gblUserGroup)
        DoCmd.SetWarnings True
        MsgBox ("gblUserGroup = " & gblUserGroup)
        DoCmd.Close
        Exit Sub
    Else
        If gblAction = 0 Then
            MsgBox ("The password entered is incorrect.  Please try again.")
            gblAction = 2
        Else
            MsgBox ("You not approved as a CARE User.  Contact the CARE Administrator.")
            DoCmd.Quit
        End If
    End If
End Sub

These tables contain parameters that are used later in the application.  They never contain more that one record, but that record needs to be there.

What do I need to do the keep from getting this warning?  

Judith
0
JudithARyan
Asked:
JudithARyan
  • 3
  • 2
  • 2
  • +1
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Private Sub Pswrd_AfterUpdate()
   
    If Me.Pswrd = DLookup("Password", "sysCareUsers", "ContactID = " & Me.UserName.Column(0)) Then
        gblUserGroup = DLookup("SecurityLevel", "sysCareUsers", "ContactID = " & Me.UserName.Column(0))
        'Save info into sysUser and sysUsers tables
        ' DoCmd.SetWarnings False
        With CurrentDB
             .Execute "UPDATE sysUser SET UserID = " & gblUserID, dbFailOnError
             ' or may need parens .Execute ("UPDATE sysUser SET UserID = " & gblUserID, dbFailOnError)
             .Execute "UPDATE sysUsers SET UserID = " & gblUserID, dbFailOnError
             .Execute "UPDATE sysUser SET UserGroup = " & gblUserGroup, dbFailOnError
       End With
        ' DoCmd.SetWarnings True
        MsgBox ("gblUserGroup = " & gblUserGroup)
        DoCmd.Close
        Exit Sub
    Else
        If gblAction = 0 Then
            MsgBox ("The password entered is incorrect.  Please try again.")
            gblAction = 2
        Else
            MsgBox ("You not approved as a CARE User.  Contact the CARE Administrator.")
            DoCmd.Quit
        End If
    End If
End Sub
0
 
Eric ShermanAccountant/DeveloperCommented:
Are you getting the Delete message or the Update message??

Your SQL is not performing any Delete actions!!!

ET
0
 
Rey Obrero (Capricorn1)Commented:
try replacing these lines

        DoCmd.RunSQL ("UPDATE sysUser SET UserID = " & gblUserID)
         DoCmd.RunSQL ("UPDATE sysUsers SET UserID = " & gblUserID)
         DoCmd.RunSQL ("UPDATE sysUser SET UserGroup = " & gblUserGroup)

with

DoCmd.RunSQL ("UPDATE sysUsers SET UserID = " & gblUserID & " , UserGroup = " & gblUserGroup)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
It's just a bad all around idea to use SetWarnings False/True for several reasons.

Using the Execute Method of CurrentDB avoids the prompts AND ... with dbFailOnError will render erros that you WANT to know about ... that SetWarnings will not.
0
 
JudithARyanAuthor Commented:
DatabaseMX, I tried your .Execute method and got Compile error: Expected end of statement and the entire set of rows went red instead of black.

What am I missing.

Eric - I'm getting a delete warning even thought I'm not deleting anything.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Try the syntax with the open and closing parens ....

 .Execute ("UPDATE sysUser SET UserID = " & gblUserID, dbFailOnError)

Not sure why you would be getting a Delete warning ...
0
 
Eric ShermanAccountant/DeveloperCommented:
Something else is generating the Delete warning ... can you load up a sample db that shows the problem??

ET
0
 
JudithARyanAuthor Commented:
Eric, you were correct!  I commented out my UPDATE statements and still got the error.  So I have to back track my code and see what I find.  

Thanks for getting me unstuck.

Judith
0
 
Rey Obrero (Capricorn1)Commented:
@JudithARyan

did you try my post at  http://#a41869118 ?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now