Docmd. run action queries? (1 Viewer)

stephaniechongg

Registered User.
Local time
Today, 14:56
Joined
Feb 5, 2016
Messages
15
I have set a prompt for the user's password before allowing the user to access the run query
Code:
Private Sub imgIncreasePayslipbyDept_Click()
   Dim EnterStaffPosition As String
   Dim strStaffPosition As String
   EnterStaffPassword = InputBox("Enter your Staff Password", "Password Required")
   If EnterStaffPassword <> "" Then
       strStaffPosition = Nz(DLookup("[StaffPosition]", "[Staff_Chelsea]", "[StaffPassword]=" & Chr(34) & EnterStaffPassword & Chr(34)), "")
       If strStaffPosition = "Store Manager" Then
        [COLOR="red"]Docmd. run action query[/COLOR]
        ElseIf strStaffPosition = "Supervisor" Then
        [COLOR="Red"]   Docmd. run action query[/COLOR]
       Else
           MsgBox "You are not a manager/supervisor!"
       End If
   End If
End Sub

I am facing difficulties running the query and i also have doubts of the view that users might see after they have ran the query. I know that you are able to use runsql but how do I go around it? :banghead:

i would appreciate your help!
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 23:56
Joined
Aug 30, 2003
Messages
36,125
Options include

CurrentDb.Execute

Or

DoCmd.OpenQuery

If the query has form references.
 

plog

Banishment Pending
Local time
Today, 01:56
Joined
May 11, 2011
Messages
11,645
Here's a link to DoCmd.OpenQuery (https://msdn.microsoft.com/en-us/library/office/ff192746.aspx).

...and i also have doubts of the view that users might see after they have ran the query

By that, do you mean to the user nothing seems different when they do run the query? If so, you are correct, the query would execue and nothing would seem to change to the user. One thing I would do is capture what is going to change (via a DCount), then after the action query see if they did in fact change (via a DCount) and show the user a message box informing them of the changes. That way they know something happened.
 

Users who are viewing this thread

Top Bottom