New Control On Form

J

Jeff C

Can I create a new control on a form which will reflect the new data entered
in a field on a sub form? Can that be bound to a parent table so that when a
new date is entered on the subform it replaces the old date in the control
and table?
 
J

John Vinson

Can I create a new control on a form which will reflect the new data entered
in a field on a sub form? Can that be bound to a parent table so that when a
new date is entered on the subform it replaces the old date in the control
and table?

Yes.

However, I'm not at ALL sure what the heck you're talking about.

A Form (or a Subform) has a Recordsource, which is either a table or a
query based on a table. Controls on a Form have a "Control Source"
property which may be the name of a field in the Recordsource query;
that control will then show (and allow you to edit) the data in that
table field. Or, the Control Source can be an expression or a function
call; in this case it will show the result of that expression but will
not be editable.

Can you give a specific example of what you are trying to accomplish?

John W. Vinson[MVP]
 
J

Jeff C

Yes. Main form based on Parent Table one to many Children. Subform based on
Child Table.....Child table has a Date field and three descriptor fields.
When I update test results on each parent the subform records the new data
and displays the test result history on the main form. Specifically when a
new record is entered on the subform I would like to have the new entry for
the date field also either displayed in a control on the main form and/or
moved into a field in the Parent table. This way I can preserve a large
number of reports and macros for sending the reports that I have made. Thank
You.
 
J

John Vinson

Yes. Main form based on Parent Table one to many Children. Subform based on
Child Table.....Child table has a Date field and three descriptor fields.
When I update test results on each parent the subform records the new data
and displays the test result history on the main form. Specifically when a
new record is entered on the subform I would like to have the new entry for
the date field also either displayed in a control on the main form and/or
moved into a field in the Parent table. This way I can preserve a large
number of reports and macros for sending the reports that I have made.

I guess I don't understand. You want to store (I presume) multiple
records of history in one record on the mainform? Or you want to store
(redundantly) the latest date on the "many" side table in the main
table?

You can *display* the most recent date in the related table on the
mainform using a textbox with a recordsource such as

=DMax("[datefield]", "[child-table-name]", "[ID] = " & [txtID])

where txtID contains the main table's linking field and ID is the
foreign key in the child table.


John W. Vinson[MVP]
 
J

Jeff C

Yes it is redundant.....but notifications are based on the most recent date
from the history record in the child table. Lacking advanced programming
knowledge I have used expressions as filters to produce reports needed and
thus I am able to send notices to 40 different departments. Rather than
rewrite everything, being able to redundantly move that date to the main form
may save that. I am open to trying to accomplish things in a better way...I
am just still learning this program. Thank you....I will try this
expression:

=DMax("[datefield]", "[child-table-name]", "[ID] = " & [txtID])

datefield is the field on the child table then child-table-name

then ID is the field on the main form I am copying the date to.....

txtID is what?


Thank you John...

John Vinson said:
Yes. Main form based on Parent Table one to many Children. Subform based on
Child Table.....Child table has a Date field and three descriptor fields.
When I update test results on each parent the subform records the new data
and displays the test result history on the main form. Specifically when a
new record is entered on the subform I would like to have the new entry for
the date field also either displayed in a control on the main form and/or
moved into a field in the Parent table. This way I can preserve a large
number of reports and macros for sending the reports that I have made.

I guess I don't understand. You want to store (I presume) multiple
records of history in one record on the mainform? Or you want to store
(redundantly) the latest date on the "many" side table in the main
table?

You can *display* the most recent date in the related table on the
mainform using a textbox with a recordsource such as

=DMax("[datefield]", "[child-table-name]", "[ID] = " & [txtID])

where txtID contains the main table's linking field and ID is the
foreign key in the child table.


John W. Vinson[MVP]
 
J

John Vinson

Yes it is redundant.....but notifications are based on the most recent date
from the history record in the child table. Lacking advanced programming
knowledge I have used expressions as filters to produce reports needed and
thus I am able to send notices to 40 different departments. Rather than
rewrite everything, being able to redundantly move that date to the main form
may save that. I am open to trying to accomplish things in a better way...I
am just still learning this program. Thank you....I will try this
expression:

=DMax("[datefield]", "[child-table-name]", "[ID] = " & [txtID])

datefield is the field on the child table then child-table-name
correct...

then ID is the field on the main form I am copying the date to.....

ID is the name of the field in the child table which you are using as
the foreign key (it will be the Child Link Field property of the
Subform control); txtID is the name of a textbox on the main form
which contains the Master Link Field = the primary key of the main
form's table.

John W. Vinson[MVP]
 
J

Jeff C

Thank You ..I will give this a shot first thing in the AM

John Vinson said:
Yes it is redundant.....but notifications are based on the most recent date
from the history record in the child table. Lacking advanced programming
knowledge I have used expressions as filters to produce reports needed and
thus I am able to send notices to 40 different departments. Rather than
rewrite everything, being able to redundantly move that date to the main form
may save that. I am open to trying to accomplish things in a better way...I
am just still learning this program. Thank you....I will try this
expression:

=DMax("[datefield]", "[child-table-name]", "[ID] = " & [txtID])

datefield is the field on the child table then child-table-name
correct...

then ID is the field on the main form I am copying the date to.....

ID is the name of the field in the child table which you are using as
the foreign key (it will be the Child Link Field property of the
Subform control); txtID is the name of a textbox on the main form
which contains the Master Link Field = the primary key of the main
form's table.

John W. Vinson[MVP]
 
J

Jeff C

The following sits in the control source of a new textbox I put on my Primary
Form

=DMax("[ReadOn]", "[Child Query]", "[ParentTable_ID]="&[ID])

[ReadOn]= Date Field in Query and Child Table
When a new value (most recent) is entered through my subform I want this
value reflected in the new text box and/or (ideally) moved into a field in
the Parent Table

[Child Query] = Name of sorted Query linked to the child table

[ParentTable_ID] = Foreign Key in Child table

[ID] = PKey in Parent Table

In my test Record I have successfully added four different Dates in January
2005...the original date in the field was 12/29/2004.

I have interchanged [Child Query] with [Child] (name if child table)
I have interchanged [ParentTable_ID] with [ChildTable_ID] (PKey in Child
Table)
I have the Query linked to the Child Table [ChildTable_ID] to [ChildTable_ID]
I have interchanged that link to the FKey also

I get a return in the field of 12/29/2004 in all the above cases

Any More thoughts? Thank You.




John Vinson said:
Yes it is redundant.....but notifications are based on the most recent date
from the history record in the child table. Lacking advanced programming
knowledge I have used expressions as filters to produce reports needed and
thus I am able to send notices to 40 different departments. Rather than
rewrite everything, being able to redundantly move that date to the main form
may save that. I am open to trying to accomplish things in a better way...I
am just still learning this program. Thank you....I will try this
expression:

=DMax("[datefield]", "[child-table-name]", "[ID] = " & [txtID])

datefield is the field on the child table then child-table-name
correct...

then ID is the field on the main form I am copying the date to.....

ID is the name of the field in the child table which you are using as
the foreign key (it will be the Child Link Field property of the
Subform control); txtID is the name of a textbox on the main form
which contains the Master Link Field = the primary key of the main
form's table.

John W. Vinson[MVP]
 
J

Jeff C

=DMax("[ReadOn]","[Child Query]","[ParentTable_ID] = " & [ID])
and by correcting relationship of Query to Child

Parent PKey to Child FKey : Child PKey to the same field in the Query

It Works!!!! Thank You John...you and the other MVPs are great.

Now .... To get my reports correct...based on the value in this text box.

John Vinson said:
Yes it is redundant.....but notifications are based on the most recent date
from the history record in the child table. Lacking advanced programming
knowledge I have used expressions as filters to produce reports needed and
thus I am able to send notices to 40 different departments. Rather than
rewrite everything, being able to redundantly move that date to the main form
may save that. I am open to trying to accomplish things in a better way...I
am just still learning this program. Thank you....I will try this
expression:

=DMax("[datefield]", "[child-table-name]", "[ID] = " & [txtID])

datefield is the field on the child table then child-table-name
correct...

then ID is the field on the main form I am copying the date to.....

ID is the name of the field in the child table which you are using as
the foreign key (it will be the Child Link Field property of the
Subform control); txtID is the name of a textbox on the main form
which contains the Master Link Field = the primary key of the main
form's table.

John W. Vinson[MVP]
 
Top