crhodus
04-04-2001, 02:31 PM
I want to have the data in Form 1 automatically saved whenever someone click on a button to open Form 2. The button is located on Form 1.
Can I simply copy the code from an auto-generated save button into the code of my auto-generated open button?
I'm not sure of the correct snytax. I haven't dealt with VBA very much.
Here is the syntax from the two buttons that I am refering to.
----------------------------------------
Private Sub SaveCompanyRecord_Click()
On Error GoTo Err_SaveCompanyRecord_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_SaveCompanyRecord_Click:
Exit Sub
Err_SaveCompanyRecord_Click:
MsgBox Err.Description
Resume Exit_SaveCompanyRecord_Click
End Sub
----------------------------------------
Private Sub Open__Project_Click()
On Error GoTo Err_Open__Project_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Project_Form"
stLinkCriteria = "[company_id]=" & "'" & Me![comp_id] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Open__Project_Click:
Exit Sub
Err_Open__Project_Click:
MsgBox Err.Description
Resume Exit_Open__Project_Click
End Sub
--------------------------------------
If anyone can help, then thanks!
Can I simply copy the code from an auto-generated save button into the code of my auto-generated open button?
I'm not sure of the correct snytax. I haven't dealt with VBA very much.
Here is the syntax from the two buttons that I am refering to.
----------------------------------------
Private Sub SaveCompanyRecord_Click()
On Error GoTo Err_SaveCompanyRecord_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_SaveCompanyRecord_Click:
Exit Sub
Err_SaveCompanyRecord_Click:
MsgBox Err.Description
Resume Exit_SaveCompanyRecord_Click
End Sub
----------------------------------------
Private Sub Open__Project_Click()
On Error GoTo Err_Open__Project_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Project_Form"
stLinkCriteria = "[company_id]=" & "'" & Me![comp_id] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Open__Project_Click:
Exit Sub
Err_Open__Project_Click:
MsgBox Err.Description
Resume Exit_Open__Project_Click
End Sub
--------------------------------------
If anyone can help, then thanks!