Hi lin, from the rating you gave these forums you seem disapointed. What could we do to improve your rating?
Getting clear, easy to understand answers to questions is usually accomplished only with quite an exchange of information.
If you are just starting to use code to make changes to tables this might seem somewhat dificult. However the learning curve for this type of code is easy!
Your request seems very straight forward, but in order to give you some help we will probably need to ask several questions of you about your tables, "do they have the same number of fields?, are the fields the same datatype, and so on.
Listed below is an example I just ran on a couple sample tables. If you have questions regarding this example feel free to email them or post them here.
This example assumes that Table1 and Table 2
each have fields named Field1 and Field2 and
that both tables have the same data type for Field1 and 2
This example form is bound to Table1.
When the record you want to copy to Table2
is displayed on your form, click the button
named Command0 and the values of Field1 and Field2
from the current record will be inserted into Table2.
Private Sub Command0_Click()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("Table2"
'the ( Me.Field1 ) is a field on my form that I want to
'include in the new record in table 2
'the ( !Field1 ) is the field in table 2 that
'is getting the data.
With rs
.AddNew
!Field1 = Me.Field1
!Field2 = Me.Field2
.Update
End With
rs.Close
Set db = Nothing
End Sub