Auto Fill

Z

zyus

I hv this tbl structure that i key in thru form

No Recdate Amt
1 02-04-08 500.00
2 02-04-08 500.00

Want to know how to auto default the date & amt on 2nd record and it will
follow the same date & amt entered on the 1st record...Of course user can
amend the date/value....TQ
 
K

Klatuu

Use the form's After Upate event to populate the Default Value property of
the controls you want to carry forward:

Me.MyControl.DefaultValue = Me.MyControl
 
J

John F.

I have a form which opens records on a table; I use the "Add New" button on
the navigator to open a new record. Even though I use the following code in
the form's After_Update event,the default values are not added. In fact, when
I add the new record, the program doesn't seem to 'step into' the form's
After_Update event at all (at least, a breakpoint inserted at, say
"Me.tbAdmitdate" never halts the program's execution.)

Private Sub Form_AfterUpdate()
Me.tbRecNum.DefaultValue = Me.tbRecNum
Me.tbAdmitdate.DefaultValue = Me.tbAdmitdate
Me.tbServicedate.DefaultValue = DateAdd("d", 1, Me.tbServicedate.Value)
'add a day to get next servicedate automatically

End Sub

Could you please explain this behaviour and suggest a different way of
getting the default values inserted?

Thank you.

johno
 
K

Klatuu

The After Update event doesn't fire until you try to close the form, change
to a different record which includes adding a new record, or take some action
to explicitly save the record.
Using the technique you are using does work, but you will not actually see
the values on the form until you begin entering data in the new record.
 
J

John F.

Hi, Klatuu:

I still seem to have the problem. I even removed the default value from the
fields in the table designer, to avoid any interference with the values I'm
tryng to replicate. I'm still suspicious that the program break doesn't
happen during the form's After_Update event -- shouldn't that happen any time
that the program is stepping into that event?

Best,

johno
 
K

Klatuu

It just dawned on me what the problem may be. The After Update event does
not fire unless you make a change to a record. In other words, you have to
dirty the form. So if you are on record A, but make no changes and click the
button to add a new record, the After Update event does not fire.

What you might try is putting the same code in the form's Current event.
That way, as soon as record A becomes the current record, its values will be
loaded as the default values. But you still need the code in the after
update event so that if one of the values changes, the default value will
also change.

I would suggest you move the code to set the default values to a sub and
call the sub from the form currrent and after update events.
 

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