subforms to autopopulate from main form

G

Guest

I am trying to figure out how to make several subform fields autopopulate
from what I enter into a top field. For example, in the main form I have a
few fields and one of them is a date field. When I enter a date in the date
field I want all of the subforms to populate this date in their respective
date field. As I have it now if I manually click on an option in each of the
subforms so that the subform becomes the active control it will autopopulate
that date field because I have placed in each form under the On Dirty section
the following code:
If Me.NewRecord Then
Me!kDate = Me.Parent!Txt64
End If

kDate is the date field in each of the subforms and Txt64 is the unbound
field in the main form where a user enters the date. I want it now so that
when they enter the date in the Txt64 field and hit enter or whatever it then
populates each subform with that date instead of them having to manually
click on each subform section to make it populate. How can I do this?

Thanks
 
J

John Vinson

I am trying to figure out how to make several subform fields autopopulate
from what I enter into a top field. For example, in the main form I have a
few fields and one of them is a date field. When I enter a date in the date
field I want all of the subforms to populate this date in their respective
date field. As I have it now if I manually click on an option in each of the
subforms so that the subform becomes the active control it will autopopulate
that date field because I have placed in each form under the On Dirty section
the following code:
If Me.NewRecord Then
Me!kDate = Me.Parent!Txt64
End If

kDate is the date field in each of the subforms and Txt64 is the unbound
field in the main form where a user enters the date. I want it now so that
when they enter the date in the Txt64 field and hit enter or whatever it then
populates each subform with that date instead of them having to manually
click on each subform section to make it populate. How can I do this?

Thanks

The first question is - WHY do you want to store this date field
redundantly in your child table? It's almost certainly a Bad Idea to
do so.

If you really do want to do so... include the date field in the Master
Link Field and Child Link Field properties of the subform control(s).
But I think it's a Bad Idea nonetheless!

John W. Vinson[MVP]
 
G

Guest

John,

I am not quite sure I understand what you mean as far as storing it in the
master link field and the child. My master form is just a basic form where
someone selects a person and there is an unbound box where they enter a date.
The subforms all link to another table called responses. Each subform
represents a question from 1 to 24. The reason I originally had it so that
each question will autopopulate is because not all questions will be answered
so when they select the Yes, No, or NA to the question number it would go
ahead and store the date with it for reporting on specific questions answered
within a certain date range. The problem now is they want all questions to
default to the date already being there because most questions will have the
same date. For the few that don't they will just manually change the date and
the ones that are not answered they will blank out the date and uncheck the
response. My first thought was to create a basic table that just stores a
date. When I user goes to open the form it will run an append query which
will prompt them for a date to use and when they enter it, it will store the
date in the table. Then the form will continue to open. I was hoping to go
into each subform and somehow make the date field that is there now point to
the other table that is storing the date but when I went in and created a
textbox and tell it the default value is kdate2!kdate it just generates
Name#? when the form is open. How can I create a macro or something that will
force either a date I enter in the main form or from a table to run and place
in all of the other date fields on the form. I am just trying to automate all
of the responses to the 24 questions to be Yes with the date entered and then
in the few cases where the date is different they can change that manually.
Is there some VB code I can place in each subform that on Open it will make
the answer Yes and the date equal to whatever is in the date field of the new
date table that is storing the date or anything to do what I want it to?

Thanks,
Dale
 
G

Guest

John,

I figured out what you meant by Child Link and Master link. I managed to get
it to work so it would autopopulate the date field. The only problem now is
the way it defaults the response and the date does not allow it to actually
store to the response table. It requires that I select something other then
the default Yes in order to make it store. Is there a command or macro or
something I can do that will force it to store the defaulted data?
 

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