G
Guest
I have set up code in my forms to make sure certain fields are filled in
before the user exits because they are mandatory for the record to save. All
of them work except one, the Grant_Type field doesn't check. When I exit,
the record doesn't save because it has no grant_type, but the check doesn't
prompt.
Private Sub Command82_Click()
' This closes the current form and opens the Main form
' First make sure all necessary values are entered
If IsNull(Me.Grant_Type) Then GoTo NoType
If IsNull(Me.Grant_Dept) Then GoTo NoDept
If IsNull(Me.Fund_Amt) Then GoTo NoAmt
If IsNull(Me.Applicant) Then GoTo NoApplicant
If IsNull(Me.County) Then GoTo NoCounty
If IsNull(Me.Project_Name) Then GoTo NoName
' If so, turn the mouse into an hourglass
DoCmd.Hourglass True
' Don't show screen changes
DoCmd.Echo False, ""
' Save the new record
RunCommand acCmdSaveRecord
' The New Projects screen closes
DoCmd.Close acForm, "FrmProjEntry_HB267"
' The Main Form opens
DoCmd.OpenForm "FrmMain", acNormal
DoCmd.Maximize
' Show the screen changes again
DoCmd.Echo True, ""
' Turn the mouse back into a cursor
DoCmd.Hourglass False
ExitNice:
Exit Sub
McrFormNavigation_CloseAndSaveNew_Err:
MsgBox Error$
MsgBox "There was an error...", vbOKCancel, Whoops
GoTo ExitNice
NoCounty:
MsgBox "Please Enter a County", vbOKOnly
Cancel = True
GoTo ExitNice
NoType:
MsgBox "Please Enter a Fund Type", vbOKOnly
Cancel = True
GoTo ExitNice
NoDept:
MsgBox "Please Enter a Grant Department", vbOKOnly
Cancel = True
GoTo ExitNice
NoAmt:
MsgBox "Please Enter a Fund Amount", vbOKOnly
Cancel = True
GoTo ExitNice
NoApplicant:
MsgBox "Please Enter an Applicant", vbOKOnly
Cancel = True
GoTo ExitNice
NoName:
MsgBox "Please Enter a Project Name/Title", vbOKOnly
Cancel = True
GoTo ExitNice
End Sub
before the user exits because they are mandatory for the record to save. All
of them work except one, the Grant_Type field doesn't check. When I exit,
the record doesn't save because it has no grant_type, but the check doesn't
prompt.
Private Sub Command82_Click()
' This closes the current form and opens the Main form
' First make sure all necessary values are entered
If IsNull(Me.Grant_Type) Then GoTo NoType
If IsNull(Me.Grant_Dept) Then GoTo NoDept
If IsNull(Me.Fund_Amt) Then GoTo NoAmt
If IsNull(Me.Applicant) Then GoTo NoApplicant
If IsNull(Me.County) Then GoTo NoCounty
If IsNull(Me.Project_Name) Then GoTo NoName
' If so, turn the mouse into an hourglass
DoCmd.Hourglass True
' Don't show screen changes
DoCmd.Echo False, ""
' Save the new record
RunCommand acCmdSaveRecord
' The New Projects screen closes
DoCmd.Close acForm, "FrmProjEntry_HB267"
' The Main Form opens
DoCmd.OpenForm "FrmMain", acNormal
DoCmd.Maximize
' Show the screen changes again
DoCmd.Echo True, ""
' Turn the mouse back into a cursor
DoCmd.Hourglass False
ExitNice:
Exit Sub
McrFormNavigation_CloseAndSaveNew_Err:
MsgBox Error$
MsgBox "There was an error...", vbOKCancel, Whoops
GoTo ExitNice
NoCounty:
MsgBox "Please Enter a County", vbOKOnly
Cancel = True
GoTo ExitNice
NoType:
MsgBox "Please Enter a Fund Type", vbOKOnly
Cancel = True
GoTo ExitNice
NoDept:
MsgBox "Please Enter a Grant Department", vbOKOnly
Cancel = True
GoTo ExitNice
NoAmt:
MsgBox "Please Enter a Fund Amount", vbOKOnly
Cancel = True
GoTo ExitNice
NoApplicant:
MsgBox "Please Enter an Applicant", vbOKOnly
Cancel = True
GoTo ExitNice
NoName:
MsgBox "Please Enter a Project Name/Title", vbOKOnly
Cancel = True
GoTo ExitNice
End Sub