Solved

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

Posted on 2016-11-01
9
42 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

937 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

10 Experts available now in Live!

Get 1:1 Help Now