Setting Form Control Value Parameter

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Access 97 - Advanced User (but not programmer).

I have a form that has two dates on it that represent
report start/end dates. I have the end date default to
Date()-3. I want the Start date to be the 1st day of the
current month OR preferred is for the user to be able to
change the date and it stays that date until changed
(every time you load the form). I was messing with
DefaultValue in VB but couldn't find way to change the
DefaultValue on the form programmatically.

I know it's simple for you guys...thanks for your help!

Mike
 
Access 97 - Advanced User (but not programmer).

I have a form that has two dates on it that represent
report start/end dates. I have the end date default to
Date()-3. I want the Start date to be the 1st day of the
current month OR preferred is for the user to be able to
change the date and it stays that date until changed
(every time you load the form). I was messing with
DefaultValue in VB but couldn't find way to change the
DefaultValue on the form programmatically.

I know it's simple for you guys...thanks for your help!

Mike

Set the Default Value property of the textbox to:
=Date()-DatePart("d",Date())+1

Use the AfterUpdate event to re-set it:
Private Sub txtStartDate_AfterUpdate()
Me.txtStartDate.DefaultValue = Me.txtStartDate
End Sub

The form will open with the first of the month as default, but then
when the user changes it the changed value will be the default until
it is changed again or the form closes and re-opens.

- Jim
 
Outstanding...thanks Jim!
-----Original Message-----


Set the Default Value property of the textbox to:
=Date()-DatePart("d",Date())+1

Use the AfterUpdate event to re-set it:
Private Sub txtStartDate_AfterUpdate()
Me.txtStartDate.DefaultValue = Me.txtStartDate
End Sub

The form will open with the first of the month as default, but then
when the user changes it the changed value will be the default until
it is changed again or the form closes and re-opens.

- Jim

.
 
Oops! Two things came from this...

1) I'd like the date to stay the same as the last change
until changed again, even after the form closes and
reopens. Should I make a table just to hold this value?

2) When I try to change the value using the form, it
changes to 12/30/99 for a date regardless of what date
(mm/dd/yy) I put in the date box.

Any ideas?

Thanks Again...Mike
 
Oops! Two things came from this...

1) I'd like the date to stay the same as the last change
until changed again, even after the form closes and
reopens. Should I make a table just to hold this value?
You will have to store it somewhere. A 1 record table is good for
storing info like this.

2) When I try to change the value using the form, it
changes to 12/30/99 for a date regardless of what date
(mm/dd/yy) I put in the date box.
Hmm, tha doesn't have anything to do with default value. It could be
something in the before update event. What do you have there?

- Jim
 
Back
Top