Copy Data from Subform

  • Thread starter Connell Giacomini
  • Start date
C

Connell Giacomini

I need to select a record in a subform and have a field in that record
copied to an unbound control on the main form. Using a command button and
macro I can go to the unbound control, but can't figure out how to insert
the data.

The main form is a tab-control form. It opens to an unbound text box called
WorkOrderIDSelect. Entering the Work Order ID brings up the complete record
for that ID. On the "Part History" subform, all of the work orders that use
the same part number as in the original work order are displayed in
continuous form. I need to select a record from that subform and using a
command button, go to the starting field (WorkOrderIDSelect) in the main
form and automatically insert the Work Order ID for that selected record.
 
A

Arvin Meyer [MVP]

Write a bit of code in the subform using the double-click event of
WorkOrderID. In design view of the subform, select the WorkOrderID textbox
and go to the Events tab on the property sheet, and use the combobox to
select [Event Procedure] the click on the ellipses (...) button and enter
the following code:

Private Sub WorkOrderID_DblClick(Cancel As Integer)
Me.Parent.WorkOrderIDSelect = Me.WorkOrderID
End Sub

That's it! You are now a programmer <grin>
 
C

Connell Giacomini

Arvin, your procedure does indeed take me to the main form and it does
insert the selected Work Order number into WorkOrderIDSelect. However it
does not update the form to display the record for the newly inserted ID.
I have tried to make that work by adding a Requery and also tried Repaint
and Refresh, to no avail. Can you suggest further code that will cause the
main form to update itself based on the new ID? Thanks for your help.

Arvin Meyer said:
Write a bit of code in the subform using the double-click event of
WorkOrderID. In design view of the subform, select the WorkOrderID textbox
and go to the Events tab on the property sheet, and use the combobox to
select [Event Procedure] the click on the ellipses (...) button and enter
the following code:

Private Sub WorkOrderID_DblClick(Cancel As Integer)
Me.Parent.WorkOrderIDSelect = Me.WorkOrderID
End Sub

That's it! You are now a programmer <grin>
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Connell Giacomini said:
I need to select a record in a subform and have a field in that record
copied to an unbound control on the main form. Using a command button and
macro I can go to the unbound control, but can't figure out how to insert
the data.

The main form is a tab-control form. It opens to an unbound text box
called WorkOrderIDSelect. Entering the Work Order ID brings up the
complete record for that ID. On the "Part History" subform, all of the
work orders that use the same part number as in the original work order
are displayed in continuous form. I need to select a record from that
subform and using a command button, go to the starting field
(WorkOrderIDSelect) in the main form and automatically insert the Work
Order ID for that selected record.
 
A

Arvin Meyer [MVP]

Once you've added a row in the subform you would need to Requery the main
form. Since there is no record added in the main form and since the textbox
you are writing to on the main form is unbound, there's really nothing to
requery.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Connell Giacomini said:
Arvin, your procedure does indeed take me to the main form and it does
insert the selected Work Order number into WorkOrderIDSelect. However it
does not update the form to display the record for the newly inserted ID.
I have tried to make that work by adding a Requery and also tried Repaint
and Refresh, to no avail. Can you suggest further code that will cause the
main form to update itself based on the new ID? Thanks for your help.

Arvin Meyer said:
Write a bit of code in the subform using the double-click event of
WorkOrderID. In design view of the subform, select the WorkOrderID
textbox and go to the Events tab on the property sheet, and use the
combobox to select [Event Procedure] the click on the ellipses (...)
button and enter the following code:

Private Sub WorkOrderID_DblClick(Cancel As Integer)
Me.Parent.WorkOrderIDSelect = Me.WorkOrderID
End Sub

That's it! You are now a programmer <grin>
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Connell Giacomini said:
I need to select a record in a subform and have a field in that record
copied to an unbound control on the main form. Using a command button and
macro I can go to the unbound control, but can't figure out how to insert
the data.

The main form is a tab-control form. It opens to an unbound text box
called WorkOrderIDSelect. Entering the Work Order ID brings up the
complete record for that ID. On the "Part History" subform, all of the
work orders that use the same part number as in the original work order
are displayed in continuous form. I need to select a record from that
subform and using a command button, go to the starting field
(WorkOrderIDSelect) in the main form and automatically insert the Work
Order ID for that selected record.
 
C

Connell Giacomini

I understand what you're saying, but there is no row being added to the
subform. This is just for studying the data, not for adding new data.

Arvin Meyer said:
Once you've added a row in the subform you would need to Requery the main
form. Since there is no record added in the main form and since the
textbox you are writing to on the main form is unbound, there's really
nothing to requery.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Connell Giacomini said:
Arvin, your procedure does indeed take me to the main form and it does
insert the selected Work Order number into WorkOrderIDSelect. However it
does not update the form to display the record for the newly inserted ID.
I have tried to make that work by adding a Requery and also tried Repaint
and Refresh, to no avail. Can you suggest further code that will cause
the main form to update itself based on the new ID? Thanks for your help.

Arvin Meyer said:
Write a bit of code in the subform using the double-click event of
WorkOrderID. In design view of the subform, select the WorkOrderID
textbox and go to the Events tab on the property sheet, and use the
combobox to select [Event Procedure] the click on the ellipses (...)
button and enter the following code:

Private Sub WorkOrderID_DblClick(Cancel As Integer)
Me.Parent.WorkOrderIDSelect = Me.WorkOrderID
End Sub

That's it! You are now a programmer <grin>
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


I need to select a record in a subform and have a field in that record
copied to an unbound control on the main form. Using a command button
and macro I can go to the unbound control, but can't figure out how to
insert the data.

The main form is a tab-control form. It opens to an unbound text box
called WorkOrderIDSelect. Entering the Work Order ID brings up the
complete record for that ID. On the "Part History" subform, all of the
work orders that use the same part number as in the original work order
are displayed in continuous form. I need to select a record from that
subform and using a command button, go to the starting field
(WorkOrderIDSelect) in the main form and automatically insert the Work
Order ID for that selected record.
 

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