Current Entry as Default Value in Unbound Text Box

mikeTTI

Registered User.
Local time
Tomorrow, 07:53
Joined
Oct 7, 2007
Messages
41
This is some code I was working on a while ago, and posted on this Forum:-

Code:
Dim MyDate As Date
MyDate = Me![DateFrom]
DoCmd.OpenForm "LevyReportDialog", acDesign
Me.DateFrom.DefaultValue = MyDate
[COLOR=seagreen]'MsgBox MyDate[/COLOR]
DoCmd.Close acForm, "LevyReportDialog", acSaveYes

It is supposed to save the current value of the [DateFrom] text box to the variable MyDate, then set the DefaultValue property of [DateFrom] to the value of MyDate, then save and close the form.

It returns the error message
"The Expression you entered refers to an object that is closed or doesn't exist"

As a test I used the MsgBox function above to read the value of MyDate. The resulting message box displayed the expected value, so MyDate is picking up the value from the text box and retaining it until after the Form is opened in design view.

Not sure why this isn't working. Or aternately does anyone have a better suggestion.

The text box sets a date range criteria for a number of queries.

I want like the value the user enters into the text box to become the default value for the next time the form is used.

It has been suggested previously to keep the form open instead of using the default value, but the application is frequently opened and closed, so this won't work.
 
Simple Software Solutions

From what I gather you want to retain a date into memory and use it more than once during your open session.

If that is the case then you need to be looking at using public variables declared at startup.

Read the attached article on how to use these features.

CodeMaster::cool:
http://www.icraftlimited.co.uk
 

Users who are viewing this thread

Back
Top Bottom