help with code builder

  • Thread starter Thread starter lynn atkinson
  • Start date Start date
L

lynn atkinson

I have set up a button using the wizard which opens
another form and displays the related record. I want this
button to also close the original form when it displays
the related form. Where do I put the code and what do I
say?
the existing code produced by the wizard is as follows:

Private Sub go_to_edit_worker_Click()
On Error GoTo Err_go_to_edit_worker_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "new employee edit"

stLinkCriteria = "[employee ID new]=" & Me![employee
ID new]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_go_to_edit_worker_Click:
Exit Sub

Err_go_to_edit_worker_Click:
MsgBox Err.Description
Resume Exit_go_to_edit_worker_Click

End Sub

I want to close the original form called 'worker details
filter form'

How do I go about this?

regards
 
See VBA Help on the DoCmd object and its methods.

Insert the following line after the DoCmd.OpenForm
statement:

DoCmd.Close acForm, "Your Form Name"

HTH
Kevin Sprinkel
 
I have set up a button using the wizard which opens
another form and displays the related record. I want this
button to also close the original form when it displays
the related form. Where do I put the code and what do I
say?
the existing code produced by the wizard is as follows:

Private Sub go_to_edit_worker_Click()
On Error GoTo Err_go_to_edit_worker_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "new employee edit"

stLinkCriteria = "[employee ID new]=" & Me![employee
ID new]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_go_to_edit_worker_Click:
Exit Sub

Err_go_to_edit_worker_Click:
MsgBox Err.Description
Resume Exit_go_to_edit_worker_Click

End Sub

I want to close the original form called 'worker details
filter form'

How do I go about this?

regards

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, Me.Name
 
Back
Top