A way around linking subforms with unbound controls

CarlyS

Registered User.
Local time
Today, 07:58
Joined
Oct 9, 2004
Messages
115
Does anyone know a way to automatically fill in a subform field with an unbound mainform field? Apparently you cannot link unbound fields?
 
forms!MainFormName!SubFormName.form.SubFieldName = & _
forms!MainFormName!FieldName
 
Thank you for the reply--I just need a little more help...

Where does this code go? Would it be an OnCurrent Event for the subform?

I know about as much about using code as I do about performing brain surgery. (And I am not a brain surgeon).

Thank you so much for your time!
Carly
 
I should also mention this is a date field. I tried using the SetValue function in a macro, and I get the date 12/30/1899 no matter what date I enter on the mainform.

Doesn't this mean that my macro is not setting the value? Or am I running the macro at the wrong time? I have tried it in the subform event properties for OnCurrent and Before and After Insert and each attempt still resulted in 12/30/1899. I hope that may clarify what needs to be done for someone who reads this.

Thanks again,
Carly
 
Use the AfterUpdate of the form control to store the vale in the subform.

Note that there's several Access fanatics on this site that criticize saving the same value in two places, especially if they're displayed at the same time. It's not a good idea, unless it's a key of some kind.

I think that 12/30/1899 is the date formatted value for Null.

I suspect that your subform referencing is incorrect. My earlier post has the correct syntax.
 
Great! I'll try it. Thank you so much!
 
12/30/1899 is the displayed value for a date field containing the value 0. Remember, date/time fields are double precision numbers, NOT strings. 12/30/1899 is the origin date. 1 = 12/31/1899 and -1 = 12/29/1899, etc. The decimal portion of the number contains the time.

If each subform record needs to contain the same value obtained from an unbound field on the main form, there is something wrong with your design. Add a new field to the main form's base table and store the value there, ONCE, instead of with EACH subform record.

When referencing form fields from WITHIN a form's class module, it is best to use the Me. syntax as it is more efficent, shorter, and has the advantage of intellisense. Only use the formal Forms! syntax when you are referencing a form from outside of its class module. To reference controls on the main form from a subform, use - Me.Parent.fieldname
 
Thank you Pat. I basically have a form that functions as both a schedule and data collection sheet. The design is set up so that data collection for each time of day is a new record, so that, if I would like to analyze data according to some of the schedule information, I can do so even if the same activity happens multiple times in one day. I want to store date as a key, so that I can anyalyze data according to date as well. That is why I want the date included in each subform.
You may still be right, however. This still may not be the most efficient design. It was all I could come up with. If you have any suggestions, they're always appreciated.
Best,
Carly
 
u can directly write down the unbound form's filed name in link child field, link masterfiled name property of subform
 

Users who are viewing this thread

Back
Top Bottom