fOSUserName revisited

  • Thread starter Thread starter Gary T via AccessMonster.com
  • Start date Start date
G

Gary T via AccessMonster.com

Referencing http://www.mvps.org/access/api/api0008.htm here:

I realize this is old stuff and I've run searches til I'm blue in the face
but, I'm hoping *someone* can help me out with this.

I finally got this code to work in a form I'm using. HOWEVER, the form has a
subform that needs to have the data "stamped" into it each and every time.
How do I get the information from the form =fOSUserName
() into the subform table automatically? Putting in the field's default
value bombs because ya can't enter a custom function in that area. I can get
it onto my base form easily enough with a text box. How to get that data
into the table in the subform is where I'm going nutz!

Help me, Obi Wan Kenobee!
 
While you can't set the field's Default Value to that function in the table,
you can in the form's textbox.
 
My "AddedBy", "AddedOn", "ChangedBy", "ChangedOn" fields generally don't
appear on forms (and if they do, they are disabled). In either case, I don't
worry about what the controls display while editing is going on. I just call
a generic routine in the form's BeforeUpdate event to update the underlying
field values with the current user, current time, etc at the time of the
Update.

HTH
 
George said:
My "AddedBy", "AddedOn", "ChangedBy", "ChangedOn" fields generally don't
appear on forms (and if they do, they are disabled). In either case, I don't
worry about what the controls display while editing is going on. I just call
a generic routine in the form's BeforeUpdate event to update the underlying
field values with the current user, current time, etc at the time of the
Update.
That's all well & good however, tables as a subform do not have BeforeUpdate.
They have something like OnEnter and OnExit. So far, I've been toying with
an append or update query. I'm SOOOOOO close!
 
Gary T via AccessMonster.com said:
That's all well & good however, tables as a subform do not have BeforeUpdate.
They have something like OnEnter and OnExit. So far, I've been toying with
an append or update query. I'm SOOOOOO close!

What you're talking about is the subform control on the main form that
"hosts" the actual subform. Whatever you're using as a subform is a form in
its own right, though: put the logic in its BeforeUpdate event.
 
...tables as a subform...

I have absolutely *no* idea what that means. You can't use a table in a
subform control, you have to use a form (or report). Even if you select
Table or Query when using the subform control wizard, Access will create a
new form based on that table/query and use that form as the SourceObject
for the subform control. The same thing happens if you try to "drop" a table
or query onto a form: Access creates a new form based on that table/query
and uses that new form as the SourceObject. (At least that's what happens
when I try it in Access XP/2002).

So, given that a subform control *requires* a form (or nothing) as a
SourceObject, that form has a BeforeUpdate event that will fire when changes
are made to data on the subform.

HTH,
 
Douglas said:
[quoted text clipped - 6 lines]
They have something like OnEnter and OnExit. So far, I've been toying with
an append or update query. I'm SOOOOOO close!

What you're talking about is the subform control on the main form that
"hosts" the actual subform. Whatever you're using as a subform is a form in
its own right, though: put the logic in its BeforeUpdate event.
That's odd. On my form, it's showing as a TABLE.... not a subform control.
Therefore, no BeforeUpdate event.
 
George said:
I have absolutely *no* idea what that means. You can't use a table in a
subform control, you have to use a form (or report). Even if you select
Table or Query when using the subform control wizard, Access will create a
new form based on that table/query and use that form as the SourceObject
for the subform control. The same thing happens if you try to "drop" a table
or query onto a form: Access creates a new form based on that table/query
and uses that new form as the SourceObject. (At least that's what happens
when I try it in Access XP/2002).

So, given that a subform control *requires* a form (or nothing) as a
SourceObject, that form has a BeforeUpdate event that will fire when changes
are made to data on the subform.

Honest... I wouldn't lie to ya... The source object in properties shows it as
"TABLE.tablename". The only two events are "On Enter" and "On Exit". Am I
missing something?
 
Gary said:
[quoted text clipped - 10 lines]
SourceObject, that form has a BeforeUpdate event that will fire when changes
are made to data on the subform.

Honest... I wouldn't lie to ya... The source object in properties shows it as
"TABLE.tablename". The only two events are "On Enter" and "On Exit". Am I
missing something?

I just caught it... I have a TABLE on the form NOT a SUB-FORM. Sheesh! I
got the results I wanted using macros. Kind of a kludge but, hey.... it
works.
 
Back
Top