It has been a while...

aftershokk

Registered User.
Local time
Today, 10:37
Joined
Sep 5, 2001
Messages
259
Hi, I have a form (parent table) and a subform (child table history recs)

The subform enters the user name into a field in the subform when a field has a data entered into it. This macro works fine when you run this form stand alone. When you run the master form with the sunform embedded, the macro in the subform does not work. It states the master form cannot find it?

It has been a while since I did this so any help is appreciated!
 
You have to refer to the subform with a bit different syntax than if it was a stand alone form.

See here for more.
 
thanks dont really follow,
my subform has a field named approve, when it is clicked the user name fills into the user field

so if I am on the main form and want to create this macro for a subform a refer to the fields as ME.name?
thanks
 
Me refers to the current class object - object the code is in.

What code are you specifically using?
 
The subform field named speciality calls out a macrolibrary item
after the field speciality is updated

set value command
item - [Forms]![ref_history]![USER]
expression - Environ("username")

this subform is embedded on a main form
 
If this
[Forms]![ref_history]![USER]

refers to the subform then it is wrong. When it is on a main form it would be:

[Forms]![YourMainFormnameHere]![ref_history]![Form].[USER]

The [Form]. part stays exactly as shown. Also, you refer to the subform CONTROL which houses the subform on the main form and not the subform name itself. So, if the subform control is NOT named [ref_history] then you need to use the actual name of the control - for example if it is Child08 then it would be

[Forms]![YourMainFormnameHere]![Child08]![Form].[USER]
 
the event is on a subform field but it doies run when the user is using the main form

I tried this with no luck

[Forms]![ref_form]![Form]![ref_history]![USER]

It cannot fiend the field form. My subform is named ref_history

thanks!
 
You got the Form part in the wrong place. It should be:

[Forms]![ref_form]![ref_history]![Form]![USER]

What that tells Access is that you want something on the subform and not on the subform container itself. Is the subform control on the main form really named ref_history?
 
it states it cannot find form
[Forms]![ref_form]![ref_history]![Form]![USER]

the subform is named ref_history
 
it states it cannot find form
[Forms]![ref_form]![ref_history]![Form]![USER]

the subform is named ref_history

Yes, the subform is named ref_history, but is the subform container ALSO named ref_history? If not you need to use that name instead of ref_history. And based on your error message I am guessing that the subform container is NOT named ref_history.

if you post a screenshot with the main form in design view, with the subform container selected and the properties dialog showing the names, we might be able to confirm that. (or just upload the database - with no data).
 
Okay, first of all -

1. the main form should not have both of the tables as the record source. You leave off the table which the subform is based on.

2. Why is everything locked? What is the purpose of the Search?
 
1. I will fix
2. Demographivs are pre-loaded and not editable for our users
 
Don't know about that. But using the correct name should:

The subform control is named:
ref_history_subform

NOT

ref_history (which is the name of the subform).

So you need to use ref_history_subform as the name.
 
I did that in the macro for the one I sent

[Forms]![ref_form]![ref_history_subform]![Form]![USER]

Am I missing something?
thx
 
Which macro is it (hard to look through all of them)?
 

Users who are viewing this thread

Back
Top Bottom