From To fields autofill

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi;

I have a form which has a "From" field and a "To" field. These are
measurements, not dates. The intervals are always 1.5m, so I'd like to
autofill the "From" and "To" fields. This is just to facilitate the
data-entry process. I'm confused as to what code I need to write to get this
end result. Could someone help me?

Thanks,
Casa
 
If it's always the same, why store it?

If you need to occasionally be able to change it, set the DefaultValue for
the text boxes on your form.
 
What I mean is this:

From To
0 1.5
1.5 3.0
3.0 4.5

That kind of thing. Sorry if I was unclear.
 
So are you saying you want to set the To value once the From value is keyed
in (or vice versa)?

If the difference is always 1.5, you shouldn't be storing both values.
 
Hey Casa, are you saying the To field is always 1.5 more than the From field?
If so, in the After Update event of the From field, enter:

To.Value = From.Value + 1.5
 
Douglas J Steele said:
So are you saying you want to set the To value once the From value is keyed
in (or vice versa)?

Yes. I want to set the To value once the From value is keyed in.
If the difference is always 1.5, you shouldn't be storing both values.

I think that 95% of the time the difference will be 1.5, but there will be
the odd one that will be different. In that case, the user can manually
change the number.
 
There must be something I'm doing wrong, because I get a syntax error when I
try that code.
 
What are the names of your fields? Unless they're To and From, you'll need
to change the line of code. And, to be honest, From isn't a good name to
use, as it's a reserved word.

Try renaming the text boxes to txtTo and txtFrom. Then, use

Private Sub txtFrom_AfterUpdate()
Me.txtTo = Me.txtFrom + 1.5
End Sub
 

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

Back
Top