using another field as default

J

JohnE

I have a form in which I need to do a default value of one textbox with the
value of another textbox. The max warranty txtbox default value should be
the contract warranty textbox value. Both fields are bound fields. A
majority of time the max will be the same as contract but there are times
when max is a longer time period so the user will change the number. How do
I make the max default to the contract default?
Thanks.
John
 
M

Marshall Barton

JohnE said:
I have a form in which I need to do a default value of one textbox with the
value of another textbox. The max warranty txtbox default value should be
the contract warranty textbox value. Both fields are bound fields. A
majority of time the max will be the same as contract but there are times
when max is a longer time period so the user will change the number. How do
I make the max default to the contract default?


You can not actually use the DefaultValue property for this
kind of thing because it is applied at the first keystroke
on new records. So by the time the contract warranty
textbox value gets a value, it's too late to make use of the
DefaultValue property.

Try using a little VBA code in the contract warranty
textbox's AfterUpdate event and see if it meets your needs.

If IsNull(Me,[max warranty]) Then
Me,[max warranty] = Me.[contract warranty]
End If
 
K

KARL DEWEY

This is the chicken & egg scenario. A default is used when you create a
record.
After the record is created it is not used.

You can not set the max warranty txtbox default value to the contract
warranty textbox value until contract warranty textbox has a value and it
will not have a value until the record is created.

You could add a command button to set the max warranty txtbox value to the
contract warranty textbox value.
 
J

Jeff Boyce

As you've already read, the "default" only applies to a totally new record.
Once you've entered a value in your first texbox, I believe what you're
saying is you want the value in the second textbox to match it.

Here's some untested code to put into the AfterUpdate event of the first
textbox:

Me!SecondTextbox = Me!FirstTextbox

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
J

JohnE

JohnE said:
I have a form in which I need to do a default value of one textbox with the
value of another textbox. The max warranty txtbox default value should be
the contract warranty textbox value. Both fields are bound fields. A
majority of time the max will be the same as contract but there are times
when max is a longer time period so the user will change the number. How do
I make the max default to the contract default?
Thanks.
John

Thanks to those of you that responded. I will try the different ideas and
see which one fits the need.
Thanks.
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top