Solved

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

Posted on 2016-11-01
9
35 Views
Last Modified: 2016-11-01
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
Comment
Question by:JudithARyan
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 75
ID: 41869114
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
 
LVL 19

Expert Comment

by:Eric Sherman
ID: 41869116
Are you getting the Delete message or the Update message??

Your SQL is not performing any Delete actions!!!

ET
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 41869118
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
 
LVL 75
ID: 41869122
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:JudithARyan
ID: 41869205
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
 
LVL 75
ID: 41869220
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
 
LVL 19

Accepted Solution

by:
Eric Sherman earned 500 total points
ID: 41869241
Something else is generating the Delete warning ... can you load up a sample db that shows the problem??

ET
0
 

Author Closing Comment

by:JudithARyan
ID: 41869293
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
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 41869294
@JudithARyan

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

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now