G
Graham
I have a database with two tables. I am using a form with two unbound
text boxes and combo boxes to capture user input. The problem is I
want to be able to update two tables from the same form.
The form has three fields first, surname and gender.
txtFirst
txtSurn
cboGender (values: M; F; U)
The two tables have the following fields
tblName
fields:
Person (autonumber)
First (text)
Surn (text)
tblGender
fields:
Person (autonumber)
Gender (text)
Here is my code to update the first table:
Dim rstIndi As ADODB.Recordset
Dim txtINDI As Integer
Set rstIndi = New ADODB.Recordset
rstIndi.Open "NAME", CurrentProject.Connection, adOpenStatic,
adLockOptimistic
If rstIndi.Supports(adAddNew) Then
With rstIndi
.AddNew
.Fields("First") = txtFirst
.Fields("Surn") = txtSurn
.Update
cmdReset_Click
End With
End If
rstIndi.Close
Set rstIndi = Nothing
Now the problem is when the First and Surn fields are added to tblName
it works fine, incrementing the autonumber field as required. How do
I copy the autonumber field from tblName to tblGender and add the
value selected in cboGender on the form to the field Gender, all of
course from the same submit function in the form?
Thanks
Graham
text boxes and combo boxes to capture user input. The problem is I
want to be able to update two tables from the same form.
The form has three fields first, surname and gender.
txtFirst
txtSurn
cboGender (values: M; F; U)
The two tables have the following fields
tblName
fields:
Person (autonumber)
First (text)
Surn (text)
tblGender
fields:
Person (autonumber)
Gender (text)
Here is my code to update the first table:
Dim rstIndi As ADODB.Recordset
Dim txtINDI As Integer
Set rstIndi = New ADODB.Recordset
rstIndi.Open "NAME", CurrentProject.Connection, adOpenStatic,
adLockOptimistic
If rstIndi.Supports(adAddNew) Then
With rstIndi
.AddNew
.Fields("First") = txtFirst
.Fields("Surn") = txtSurn
.Update
cmdReset_Click
End With
End If
rstIndi.Close
Set rstIndi = Nothing
Now the problem is when the First and Surn fields are added to tblName
it works fine, incrementing the autonumber field as required. How do
I copy the autonumber field from tblName to tblGender and add the
value selected in cboGender on the form to the field Gender, all of
course from the same submit function in the form?
Thanks
Graham