I had inserted a textbox called Year and a command button called Open. Upon clicking on the 'Open' button, it will link me to another page. But the problem is, if the textbox 'Year' is not filled, I wanted it to show a msgbox asking the user to type in the Year. But the code can't work. Can anyone help me with this? Thank You!
Private Sub Open_Click()
If Year = Null Then
MsgBox "Please enter the year"
Else
On Error GoTo Err_Open_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "123"
stLinkCriteria = "[Year]=" & "'" & Me![Year] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Exit_Open_Click:
Exit Sub
Err_Open_Click:
MsgBox Err.Description
Resume Exit_Open_Click
End Sub
Private Sub Open_Click()
If Year = Null Then
MsgBox "Please enter the year"
Else
On Error GoTo Err_Open_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "123"
stLinkCriteria = "[Year]=" & "'" & Me![Year] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Exit_Open_Click:
Exit Sub
Err_Open_Click:
MsgBox Err.Description
Resume Exit_Open_Click
End Sub