the command button has the following code and where actually do i put the new
code?
Private Sub Command30_Click()
On Error GoTo Err_Command30_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Admin & Finance 2"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command30_Click:
Exit Sub
Err_Command30_Click:
MsgBox Err.Description
Resume Exit_Command30_Click
End Sub
What you have is the Access wizards style of the coding needed to open
the form.
You could use, in place of all of this:
Private Sub Command30_Click()
On Error GoTo Err_Command30_Click
DoCmd.OpenForm "Admin & Finance 2", acFormDS
Exit_Command30_Click:
Exit Sub
Err_Command30_Click:
MsgBox Err.Description
Resume Exit_Command30_Click
End Sub
Or, if you wish to retain the wizard generated code style:
Private Sub Command30_Click()
On Error GoTo Err_Command30_Click
Dim stDocName As String
stDocName = "Admin & Finance 2"
DoCmd.OpenForm stDocName, acFormDS
Exit_Command30_Click:
Exit Sub
Err_Command30_Click:
MsgBox Err.Description
Resume Exit_Command30_Click
End Sub
Because you are not actually using any criteria to open the form, you
can dispense with the stLinkCriteria variable completely.