?
Solved

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

Posted on 2016-11-01
9
Medium Priority
?
74 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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
 

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 2000 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41869294
@JudithARyan

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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

801 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