kevin1478
asked on
MS Access - VBA to open a form in data entry mode
I have a table that contains a customers details and 2 addresses (all in 1 table). The 1st address is a home address and the 2nd a business address.
I have a form based on this table. The form has a VBA button to open a 2nd form so that an address can be entered. The 2nd form opened could be 1 of 2 forms, depending on the entry in a tick box which identifies the address type.
I need to change the VBA so that the 2nd form will enter details in the same record as the 1st form. For instance, at the moment if the cust_id on the main form is 12 then the 2nd form will enter details at record 13, not 12 as required. This is because the 2nd form is in data entry mode. But if I remove the acFormAdd the 2nd form opens with the previous data and not blank.
How can I open the 2nd form so that it will enter into the same record as the first but the form will 2nd form will open blank?
The actual problem is a little more complex but if I can understand a simplified version I will then apply it. I learn better that was rather than cut/past a given answer.
Any help is appreciated.
I have a form based on this table. The form has a VBA button to open a 2nd form so that an address can be entered. The 2nd form opened could be 1 of 2 forms, depending on the entry in a tick box which identifies the address type.
I need to change the VBA so that the 2nd form will enter details in the same record as the 1st form. For instance, at the moment if the cust_id on the main form is 12 then the 2nd form will enter details at record 13, not 12 as required. This is because the 2nd form is in data entry mode. But if I remove the acFormAdd the 2nd form opens with the previous data and not blank.
How can I open the 2nd form so that it will enter into the same record as the first but the form will 2nd form will open blank?
The actual problem is a little more complex but if I can understand a simplified version I will then apply it. I learn better that was rather than cut/past a given answer.
Any help is appreciated.
Private Sub Command18_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
Dim stLinkCriteria As String
If Me.business = True Then stDocName = "frm_bus_add" Else stDocName = "frm_cust_add"
DoCmd.OpenForm stDocName, , , acFormAdd, , , stLinkCriteria
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER