I have a cmd button executing the following code:
I have been thinking that I need an IF statement in there to state something like this:
Hold on have I just answered my own question. Can someone check the code for me?
Code:
Private Sub btnNewItems_Click()
On Error GoTo Err_btnNewItems_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmNewOptions"
stLinkCriteria = "[SitesID]=" & Me![sitesid]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmSitesMain", acSaveNo
Exit_btnNewItems_Click:
Exit Sub
Err_btnNewItems_Click:
MsgBox err.Description
Resume Exit_btnNewItems_Click
End Sub
I have been thinking that I need an IF statement in there to state something like this:
Code:
Private Sub btnNewItems_Click()
On Error GoTo Err_btnNewItems_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmNewOptions"
IF Me."[SitesID]" = Null then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
stLinkCriteria = "[SitesID]=" & Me![sitesid]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmSitesMain", acSaveNo
End If
Exit_btnNewItems_Click:
Exit Sub
Err_btnNewItems_Click:
MsgBox err.Description
Resume Exit_btnNewItems_Click
End Sub
Hold on have I just answered my own question. Can someone check the code for me?