Full Version: Manager Override Form
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
portman98
In the Click Event for my Delete button on my sales form, I have the following code...

'Need Manager's approval to delete a record.
'Call manager override function,DelRecOverride, to display an override form for manager to input password.
'This DelRecOverride is a Public function declared under Modules, modDelRecOverride.
'The DelRecOverride function will return True is the password is correct and likewise.


If DelRecOverride = True Then
'to continue the code to delete the record
Else
Exit Sub
End If

'to delete record.....and so on.

My problem is, the system will just continue executing the code without waiting for the answer from the
Override form (or DelRecOverride).

How to pass the control to that manager override form and remain there until the form is close then back to
the calling module to continue executing and do the neccessary?

Please help......
Larry Larsen
Hi
You could use a temp table to receive the outcome from Override form(true/false) then evaluate the value.. or consider using a global variable set in the Override form..
(just a couple of idea's)
thumbup.gif
portman98
I fact I have tried the global variable method and is the same. The system just execute the DelRecOverride() function, display the override form and continue executing the subsequent code, which is IF comparision statement like, If the global variable, gblnOverrideOK, = True then delete the record.

The alternative, temp table with have the same fate simply because the manager takes time to input the password but the system will not wait. As the result, the system assume the override fail.

This is a very basic feature but just couldnt get any clue. Any better suggestion?
Rainlover
Try an Input Box.
portman98
Hi Rainlover,

What is your input box?
Rainlover
I will come back in 30 mins

Just busy now

OK
portman98
Hi Rainlover,

I do not know there is such function, InputBox(), now I know. Thanks.

InputBox "Please enter your password"

I have to show two field on that form....

1. ComboBox to select the manager ID
2. password

How the InputBox() deal with this requirements?
Rainlover
Try This

Create a form that opens when you need the Manager Override.

Put an uncontroled Text Box on the form with an input mask of Password. Call it TxtPassword

Dim Password As String

Password = "ABC"

If Me.TxtPassword = Password Then

DoCmd. "Whatever action you want"


Else
MsgBox "Denied", vbExclamation, "Incorrect password"

DoCmd.Close

End If

Hope this helps
portman98
In my override form, there are two unbound fields, Manager ID comboBox and Password.

Manager ID field will refer my employee table, tblEmployeePorfile.


Is exactly what I am facing right now, the system will not wait for the manager to input, after displyed the said form. The system will continue to do the job by assuming override fail.
Rainlover
Else
MsgBox "Denied", vbExclamation, "Incorrect password"

Me.Undo

DoCmd.Close

Does this help. It should remove what the user inputed.

Just on a technical note. Fields are found in Tables and Queries. In forms these are refered to as Controls. These controls may be text Boxes or combo boxes etc.
portman98
Will be back much later.
portman98
Hi Rainlover,


I have tried many methods over the weekeend but still couldnt find a suitable one.

Any more suggestion please?
Rainlover
So let me see if I have this right.

A user enters data.
Then for some reason the manager needs to approve.
But the manager is not available.
So you want to keep the data in limbo until the manager is available to approve.

Is this Right?
portman98
No.

Is like this...

A user enters data.
Then for some reason the manager needs to approve.
The system has to display an override pop-up screen, which it did.
The manager select his ID and input password and click approve, all in the pop-up screen.
Close the pop-up screen.
Then the system is to continue to do the job (eg, delete the record) if override approved.

The problem now I face is that the manager needs a few seconds to select his ID and input the password, which is the true fact. But the system will just continue to execute the code after displayed the pop-up form without waiting and since the manager has yet to complete the input, of course the override status is not approved and therefore the system assume the override failed.
Rainlover
If this does not work then please post your code.

After the system displays the pop up screen End your procedure there.
When the manager completes the pop up form and closes it then add the balance of your code there.

What I don't understand is how does the form pop up displays on the managers screen based upon an action on the users screen.
portman98
Logical it seems this is the only way, like you mention end the procedure here and continue over there.

Unfortunately, there are a lot of information in the main form (the currently opened record) to refer and verify before deleteing it, therefore I cannot put the code in the pop-up.

Please refer to my first post for the code. Is very simple and I think is the matter of programming logic issue unless VBA allows us to pause the code until the pop-up screen closed.
Rainlover
Your OP only has an outline not the real code.

You need to post all of the relivant code for me to understand.
portman98
Sorry for the late reply. I wasn't feeling well for the past few days and also not able to finish simplifying the system just to post it up.

For faster solution I hv developed a small sample. Pls see the attached.

If you click the Delete Record button, by right you should not get the Not Approved message because the manager is yet to make the decision.

Try it.
Rainlover
QUOTE
My problem is, the system will just continue executing the code without waiting for the answer from the
Override form (or DelRecOverride).
I am lost.

I tried your example and the form opens and waits for an answer.

What am I missing here?
portman98
Is the "Not Approved" message displayed too once you click the delete record button ?

If is not displayed,which mean is correct.
If is displayed, which mean is wrong.
Rainlover
I still do not understand. Sorry.

I click the delete abd a pop up appears. I do not have the name and password so it closes.

Nothing else happens.

What do you want to happen??
portman98
You should have 2 user records and their password is '123'.

Due to the said problem of not able to pause the code to wait for manager's approval, the system has continue the delete command and deleted the manager record instead of the sales record due to that the manager form has the focus at the moment of deletion.

Sorry if I confuse you further with the above, may be is clearer if you refer to the code.

Also for your better understanding, please put a manager record in the manager table with you own wish and try out.

The system shoud do the job in the below sequence...

0. Insert a manager name and password in manager table.
1. Hit delete record button (action)
2. Manager form displayed (respond) without the Not Approved form (respond)
3. Delete the sales record instead of the manager record.

Thanks.
Rainlover
I see it deletes the Manager not the Sales Record. And you want it to delete the sales record. Is this right?
adaytay
Change the line of code in the Sales form under btnDel_Click() that's this:

CODE
DoCmd.OpenForm stDocName, , , stLinkCriteria


to this:

CODE
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog


This will force the code to pause while you complete the Manager form, and then will continue the code once it's been closed (and there's something in global gBlnApproved)

Hope this helps,

Ad
portman98
Hi adaytay,

Oh yes......it works perfectly. Thanks a lot.

And a special thanks to Des for your patient and kindness.
(btw, refer to your question, yes, I want to delete the sale record).

Thanks again. yayhandclap.gif
adaytay
No probs.

Sometimes it just takes a new set of eyes to look at something and spot it. Of course, luckily I've also had to do what you're trying to do, a number of times in my systems here!

Ad
Rainlover
Adam

Thanks for jumping in during my temporary absence.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.