[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2016-11-01
9
Medium Priority
?
83 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
Independent Software Vendors: 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!

 
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

Technology Partners: 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!

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

649 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