Using an Event to poplulate a table

  • Thread starter tg112001 via AccessMonster.com
  • Start date
T

tg112001 via AccessMonster.com

Hi,

I have a form with 3 text boxes. These text boxes have an expression in
their Control Sources such as pulling the network ID of the user
[=fOSUserName()], current time [=Now()] & server name ["Srvr1"].

The user will never see these text boxes but I would need the values added to
1 line on a table via an On Close or On Click event. Can someone help me
with the coding of this please?

Thanks!
 
T

tg112001 via AccessMonster.com

NEVER MIND! I FIGURED IT OUT.
Hi,

I have a form with 3 text boxes. These text boxes have an expression in
their Control Sources such as pulling the network ID of the user
[=fOSUserName()], current time [=Now()] & server name ["Srvr1"].

The user will never see these text boxes but I would need the values added to
1 line on a table via an On Close or On Click event. Can someone help me
with the coding of this please?

Thanks!
 
R

Rob Parker

Assuming that you have fields in your form's recordsource (table or
(updateable) query) for these three items, the standard way of doing this is
to use the form's BeforeUpdate event to populate the fields. This ensures
that they always show information regarding the latest data entry or edit,
but they will not change if a user simply views the record in the form. And
you don't even need hidden textboxes on the form for the data; all you need
is code such as:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.UserName = fOSUserName()
Me.LastUpdated = Now()
Me.ServerName = "Srvr1"
End Sub

Substitute the names of the fields in your table for UserName, LastUpdated
and ServerName. BTW, if you are hard-coding "Srvr1" as a text string, it
will never change, so why bother recording it?

HTH,

Rob
 

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