How to return a form value mid procedure?

IqbalS

Registered User.
Local time
Today, 21:32
Joined
Apr 23, 2008
Messages
13
Hi I was wondering whether anybody could help me - I have built a little form where the user can select dates and it stores the value. What I need is some advice on how I can make it that on clicking a button it opens the date form (which i'll set to popup and modal), let the user fill it out and when it closes use the information for the rest of the procedure.

I intend them to fill out the dates they want to and pass the value into an sql string to return the results for that period.

I had a quick go at this and if I use the Openform command it just continues with the rest of the procedure before it has the values! I'm sure this is really simple but i just can't see it at the moment. Please help!

Thanks in advance!
 
In the OpenForm command, use the acDialog argument and code will stop until the form is either closed or hidden.
 
Thanks for your reply, although I couldn't get it working to start... the argument works if the view is not acdesign, works great.

Thats a much better solution than what I had brewing...!! Thanks again
 
I'm stuck again :( I've made this lovely form to be modal and when it closes its takes its values and happily continues the procedure. The only problem is if someone was to close the form without the filling the values - (it continues with no dates!) I can disable the close button but there might be a geniune reason to cancel out.

I think I need to use the cancel as integer in the form procedure but as the form closes by a button i'm not quite sure how to go around this? How would it report back to the orginal procedure it was cancelled?

Thanks in advance!
 
It might help to see your code, but generally I would test for valid entry and quit if you don't have it. Since you're looking for a date try:

If Not IsDate(YourValueHere) Then
 
ahh ha, i'm being a little dumb. just need to switch it around a little: - instead of validating on the close of the form i'll consider:

1. click button
2. open form to select dates
3. close date form & return values to first procedure
4. check value returned -> if null then exit sub else continue

I'll try that tomorrow, thanks for your help again.
 
No problemo. That sounds appropriate. If you wanted to force data entry I'd do it on the second form, but if they can cancel out it makes more sense to do it in the first.
 

Users who are viewing this thread

Back
Top Bottom