C
CDF
Hi,
I'm having trouble working out the following.
I've got a 2 tables (tbl_Customer & tbl_Vehicle) linked by a
Customer_ID field with a 1:Many relationship (1 customer (Customer_ID
(PK)) can have many vehicles (Customer_ID (Fk))).
On the Customer Form the Customer_ID field is filled by Autonumber.
After filling in the customer form you have the option to add a
vehicle to this customer by clicking an 'Add Vehicle' button which
saves the current record and pops up a modal form with Vehicle
information.
This button has the following vb code in the onclick property:
--------------------------------------------------
Private Sub AddNewVehicle_Click()
On Error GoTo Err_AddNewVehicle_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
stDocName = "Vehicle Installation Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Exit_AddNewVehicle_Click:
Exit Sub
Err_AddNewVehicle_Click:
MsgBox Err.Description
Resume Exit_AddNewVehicle_Click
End Sub
--------------------------------------------------
My problem is that I can't work out what code to 'write' to
automatically take the Customer_ID (which was automatically generated
by autonumber) from the Current Record of the Customer form and Paste
it into the Vehicle form so that you don't have to manually type it
in. I assume the code will go AFTER the 'go to new record command',
but I'm not a programmer so am not familiar with 'VB syntax' but
understand it when told the correct code. My VB 'experience' is
trolling these newsgroups and finding the code I need, but I cannot
find an answer to this question which I'm sure is common place in
relational databases.
I appreciate any help.
I'm having trouble working out the following.
I've got a 2 tables (tbl_Customer & tbl_Vehicle) linked by a
Customer_ID field with a 1:Many relationship (1 customer (Customer_ID
(PK)) can have many vehicles (Customer_ID (Fk))).
On the Customer Form the Customer_ID field is filled by Autonumber.
After filling in the customer form you have the option to add a
vehicle to this customer by clicking an 'Add Vehicle' button which
saves the current record and pops up a modal form with Vehicle
information.
This button has the following vb code in the onclick property:
--------------------------------------------------
Private Sub AddNewVehicle_Click()
On Error GoTo Err_AddNewVehicle_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
stDocName = "Vehicle Installation Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Exit_AddNewVehicle_Click:
Exit Sub
Err_AddNewVehicle_Click:
MsgBox Err.Description
Resume Exit_AddNewVehicle_Click
End Sub
--------------------------------------------------
My problem is that I can't work out what code to 'write' to
automatically take the Customer_ID (which was automatically generated
by autonumber) from the Current Record of the Customer form and Paste
it into the Vehicle form so that you don't have to manually type it
in. I assume the code will go AFTER the 'go to new record command',
but I'm not a programmer so am not familiar with 'VB syntax' but
understand it when told the correct code. My VB 'experience' is
trolling these newsgroups and finding the code I need, but I cannot
find an answer to this question which I'm sure is common place in
relational databases.
I appreciate any help.