How to autofill a field on a form

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
 
P

pietlinden

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
 
T

tkelley via AccessMonster.com

More than one option ... What value do you want to be in the field, and where
is it coming from?
 
B

Ben

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
 
T

tkelley via AccessMonster.com

in the On Current event try this:

If isnull(MyField) then
MyField = MyVariable
EndIf
T,

I just want to populate a text field from a variable. Any idea? Thanks,

Ben
More than one option ... What value do you want to be in the field, and where
is it coming from?
[quoted text clipped - 11 lines]
 
J

John Vinson

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
 

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