Command button in a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with 2 subforms in it. How do I create a command button with VB
or a macro to copy data from 2 seperate fields in one subform to 2 fields in
the other subform simultaneously? Please explain or show me how to or include
examples of coding to do this. Thank You.
 
I have a form with 2 subforms in it. How do I create a command button with VB
or a macro to copy data from 2 seperate fields in one subform to 2 fields in
the other subform simultaneously? Please explain or show me how to or include
examples of coding to do this. Thank You.

The first thing to realize is that data is NOT stored in subforms. You
are storing the data *in tables*, and using subforms to display that
data. An Update query updating the second subform's recordsource table
from the first's would be one possible approach.

However... storing the same data in two different tables is a very
questionable design. Could you explain the nature of this data and of
the tables concerned?

John W. Vinson[MVP]
 
Sorry, I'm a little new at this and did not think of it that way.
The table connected to the form I want to copy from contains a list of part
numbers and part descriptions. The other subform displays ordering or
exchange data for equipment. To prevent mistakes I want a certain record from
the first subform to be displayed in a line in the second b.m.o selecting the
part number or part description in the first subform and copying the number
or description and the related number or description to the 2 fields in the
second subform with a command button to make copying easier.
I hope this helps and explains the problem better.
 
Sorry, I'm a little new at this and did not think of it that way.
The table connected to the form I want to copy from contains a list of part
numbers and part descriptions. The other subform displays ordering or
exchange data for equipment. To prevent mistakes I want a certain record from
the first subform to be displayed in a line in the second b.m.o selecting the
part number or part description in the first subform and copying the number
or description and the related number or description to the 2 fields in the
second subform with a command button to make copying easier.
I hope this helps and explains the problem better.

I would suggest using a Combo Box based on the parts table on the
second form. The user could select the part number and see the
description for that part in the second column of the combo box.

To display it in a textbox even when the combo isn't dropped down, set
the Control Source of a textbox to

=cboPartNo.Column(1)

where cboPartNo is the Name of the combo box and (1) means the second
column of that combo's query - the Column property is zero based.

Your second form's table should NOT have a field for the part
description. That should exist only in the parts table.

John W. Vinson[MVP]
 
Back
Top