How to autofill a field on a form

  • Thread starter Thread starter Ben
  • Start date Start date
B

Ben

Hi all,

I have a form for adding new records, I would like to have one of the field
to be automatically filed in everytime a user clicks next in the record
navigation button on the bottom of the form.

I was able to fill in the field when the form initially lauches but on
subsequent clicks to the next record button, I don't know how.

Thanks for sharing your thoughts.

Ben
 
Hi all,

I have a form for adding new records, I would like to have one of the field
to be automatically filed in everytime a user clicks next in the record
navigation button on the bottom of the form.

I was able to fill in the field when the form initially lauches but on
subsequent clicks to the next record button, I don't know how.

Thanks for sharing your thoughts.

Ben

In the button's click event, *before* moving to the next record or new
record, set the value of the field you need filled in.
Sub cmdNextRecord_Click()
Me.MyControlName = <some value or function>
...
End Sub
 
Piet,

cmdNextRecord, is not a command button I created, I basically have a form.
I query the table and then display the data on the form. But when the user
navigate to the last record using the record navigation bar and click on the
the add record button (the * button), I want it to auto fill one of the
field. Help.

Thanks,

Ben
 
Ben said:
Hi all,

I have a form for adding new records, I would like to have one of the field
to be automatically filed in everytime a user clicks next in the record
navigation button on the bottom of the form.

I was able to fill in the field when the form initially lauches but on
subsequent clicks to the next record button, I don't know how.

Thanks for sharing your thoughts.

Ben

If you're filling it with a constant value, just set the textbox's
DefaultValue property. If you want it to be filled from some function call,
use the Form's BeforeInsert event:

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!controlname = MyFunction(...)
End Sub
 
Back
Top