Pausing Code to wait for Date Entry

music_al

Registered User.
Local time
Today, 21:16
Joined
Nov 23, 2007
Messages
200
Hi

I have a procedure which creates a new contract for an employee in the Contracts table (tbl_Contracts)

After some fields have been set a form appears in which the user will enter the Start Date of the new contract. This is done by the code...

Code:
    DoCmd.OpenForm "frm_Contract_Start_Date"
 
more code here that works out the End Date based on the duration of the contract

The problem is, the code AFTER the DoCmd line is then executed but I don't want it to. I want it to wait until a date has been passed from the form that is opened.

How would I pause the code there to make it wait for the date to be entered ?

Thank you in advance.
 
Several methods - for example

1. Add an If ....End If condition
Code:
If Nz(Me.DateField,"")="" Then Exit Sub

2. Split your code into two.
Put the code that follows date entry into the date field after update event. If necessary create 2 separate procedures
 
An alternative is to open the form in the modal popup / dialog mode.

That suspends all code execution in the calling form until the Modal form is closed.
 
Several methods - for example....

2. Split your code into two.
Put the code that follows date entry into the date field after update event. If necessary create 2 separate procedures

This is what I had done originally but I never liked the method.
 
Fair enough though to me its the most flexible approach.
 
Other than the appearance of the dialog, you could just pop up an input box to get the date at the point where you need it.
 
I added this to the end of the line of code...

Code:
    DoCmd.OpenForm "frm_Contract_Start_Date", , , , , acDialog      
    MsgBox Contract_Start_Date     'Added this just to test

And the MsgBox is still appearing at the same time the form is appearing. Have I missed something ?
 
Other than the appearance of the dialog, you could just pop up an input box to get the date at the point where you need it.

Is there any way of making the input box show a calendar when the user clicks inside the text box ?
 
Taking your last 2 posts together

1. You cold delay your message box appearing by using a timer event to run it.
Set the interval to 1000 for a one second delay.
Add msgbox code to that event and then set time interval =0 so it only runs once.

2 No you can't. You would need to create your own popup form instead of using an input box
 
It looks like its working now. Maybe I didn't save the Module before running the code again.
 

Users who are viewing this thread

Back
Top Bottom