My Assistant
![]() ![]() |
|
|
Apr 19 2005, 02:08 PM
Post
#1
|
|
|
UtterAccess Member Posts: 27 From: Scottsdale, AZ |
There may be an easy answer to this but I couldn't find it....
I have a form that I want to return a date value - basically it is a calendar control that I can use throughout my app. I want to create a function that opens the form, potentially passing it a date, opening the form, and then, when another date or cancel is clicked, closes the form, returns to the calling function, and sets the value in the designated control. something like... ============================== CODE Function GetCalValue(optional inDt as date) If IsNull(inDt) then inDt - Date() End If ' open the form here and return the value from the form??? GetCalValue = 'open form modal and return value based on user selection End Function ======================================= I am missing something obvious? Thanks. |
|
|
|
Apr 19 2005, 02:36 PM
Post
#2
|
|
|
UtterAccess Addict Posts: 100 |
No, you're not missing anything obvious. Forms just don't return values, and on destruction they delete all variables associated with themselves.
The best workaround I have found is tro create a public (global) variable and have the form clear that value on entry and set it on exit. Then just be sure that your function opens the form as a modal dialog to ensure execution freezes until the form returns. HTH, New |
|
|
|
Apr 19 2005, 04:17 PM
Post
#3
|
|
|
UtterAccess Member Posts: 27 From: Scottsdale, AZ |
Thanks. I was thinking that might be the route. I just didn't want the global variable.
That is one of the nice things with DHTML forms where you can make the form (window) return a value. Thanks. |
|
|
|
Apr 19 2005, 04:31 PM
Post
#4
|
|
|
UtterAccess Member Posts: 27 From: Scottsdale, AZ |
another question. How do I ensure code execution halts in the function until the form exits?
I could do a loop that runs as long as the form is open? Is that the method your thinking of or is there a simpler/more elegant way. Thanks. |
|
|
|
Apr 20 2005, 09:00 AM
Post
#5
|
|
|
UtterAccess Addict Posts: 100 |
the simpler more elegant way is to open the form as a modal dialog, which can be accomplished like so:
DoCmd.OpenForm(<FormName>, , , , , acDialog, <any OpenArgs you might want>) Setting the windowmode to acDialog tells it to suspend whatever is going on until the form is closed. HTH, New |
|
|
|
Apr 20 2005, 09:34 AM
Post
#6
|
|
|
UtterAccess Member Posts: 27 From: Scottsdale, AZ |
That didn't work. The form opens modal but the function I've contained the open form code in returns the default value immediately.
I'll play around a bit more and report back. |
|
|
|
Apr 20 2005, 10:50 AM
Post
#7
|
|
|
UtterAccess Addict Posts: 100 |
The only other stipulation is to make sure the form you are popping up has the Modal and Popup properties set to yes.
I use this method a lot to impose my own InputBox function because I hate the display of the default one. New |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 23rd May 2013 - 10:11 AM |