Force User to Click Button

  • Thread starter Thread starter Stockwell43
  • Start date Start date
S

Stockwell43

Hello,

How can I set up my button so that when a user updates the "OriginalDate" OR
"CompleteDate" something will pop up saying "You need to click the Turn Time
Button" of something to the fashion.

Thanks!!
 
It depends whether you want the button to execute something before or after
the OriginalDate or CompleteDate controls are updated. If the former you'd
need to declare a module level variable to determine whether the user has
already clicked the button, e.g.

Dim blnGoAhead As Boolean

Then in the button's Click event procedure set this variable to True if the
procedure executes successfully.

Then in each of the OriginalDate and CompleteDate controls' BeforeUpdate
event procedures pop up a message box, cancel the update and undo the control
if the variable is False:

Const ConMESSAGE = _
"You need to click the Turn Time Button"
Dim ctrl As Control

Set ctrl = Me.ActiveControl

If Not blnGoAhead Then
MsgBox ConMESSAGE, vbInformation, "Warning"
Cancel = True
ctrl.Undo
End If

You'll need to reset the variable to False somewhere, possibly in the form's
Current event procedure, but on the limited information you've provided its
hard to say.

If its after the control has been updated then its simply a mater of popping
up the message box:

Const ConMESSAGE = _
"You need to click the Turn Time Button"

MsgBox ConMESSAGE, vbInformation, "Warning"

In this latter context whether you'd need to confirm elsewhere that the
button has been clicked is again hard to say on the information available;
possibly the form's BeforeUpdate event procedure?

Ken Sheridan
Stafford, England
 
Are you saying that after a user updates one of a couple of possible fields,
you want to force the user to click (another) control?

If so, why? (as in 'why force the user to do something that you and Access
already know needs to happen?')

Another approach might be to have Access "click" the button after either of
those fields is updated. You could use the AfterUpdate event for each/both
of those fields, and add something like:
Call cmdTurnTime_Click

Good luck.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Hi Jeff and Ken, Thank guys for responding.

Yes, I want the user to click the button after the date is inputted in one
of the fields. The users have a habit of going to another record and not
hitting the button which throws off the elapsed days because either the days
are incorrect or there are no days at all.

The button does a calculation based on the date. So when Original date is
put in click the button and it shows number of working days between original
date and current date. When they completed the task they need to enter an
complete date and then click the button again and at that point, will
calculate the number of working days between the original date and complete
date.

Once the Complete date is entered, the clock stops so when the report is
pulled, that record will not show. Until the complete date is entered, the
records shows on the report with the amount of elapsed days between the
original date and current date.

Bottom line for all this, the user has 10 working days to complete this task
and anything outside of that is out of compliance so the manager wants to
catch it before it hits 10 days.

After a bit more detail as to where I'm going and why, to make sure the
button is clicked AFTER the complete or Original Dates are entered, which way
are you suggesting be best?

Thank you gentlemen for your assistance, most appreciated!!!
 
Got it!

I used the Call cmdTurnTime_Click in the AfterUpdate event of both fields.

Thanks Guys, I appreciate your help!!!
 
Why have the button at all? Why not just put the code in a function in the
form's module and call that in the controls' AfterUpdate event procedures?

Ken Sheridan
Stafford, England
 
The button was already there so now I just made it invisible. Although I need
to do something similar on another database and will use your suggestion in
place of the button.

Thanks Ken, appreciate the advice!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top