.adp Project - Data check not checking

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. The form is a data maintenance form which is converted to a data
entry form upon clicking the "new record" button with the code
DoCmd.GoToRecord acDataForm, Me.Name, acNewRec. There are subforms involved.


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
 
S

Sylvain Lafontaine

You don't say what type of field and what type of control is used for
Grant_Type, so it's hard to help you in finding the error. I would say that
some non-null values (for example, an empty string or a blank space) will
pass the IsNull() test but will fail the saving step.

You should take a closer look at the value that is present for this control
when entering the subroutine. Take care about any default value not only
for this control but also for this field in the backend database. Some types
of field (for example, a bit field or a BIGINT) for the table will also give
problems Access.

Finally, the official newsgroup for ADP is m.p.a.adp.sqlserver.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top