AccessForums.net is a forum dedicated to Microsoft Access, if you want to ask any Access related questions or help other members out, please join our community, the registration is free and takes only one minute.

Module not working after a day in execute only Database

I have a module that checks if certain fields in a form are filled out. It works great except for when I save the database as an execute only file the function doesn't work. All other functions of the database work in the same situation.

I am using if statements and IsNull function to see if the fields are blank.

BTW, you should really get away from having spaces in object names. (as in [CR ID])

Code:

Private Sub Command71_Click()
Dim Prompt As String
Dim DataIsMissing As Boolean
Prompt = "Not all required information has been filled out"
'assume the best - all data entered
DataIsMissing = False
'Check the controls
If Len(Trim(Me.[Date CR Performed] & "")) = 0 Then
DataIsMissing = True
End If
If Len(Trim(Me.txtCRDescription & "")) = 0 Then
DataIsMissing = True
End If
If Len(Trim(Me.Evaluation & "")) = 0 Then
DataIsMissing = True
End If
If Len(Trim(Me.Evaluation_performed_by & "")) = 0 Then
DataIsMissing = True
End If
If Len(Trim(Me.Evaluation_title & "")) = 0 Then
DataIsMissing = True
End If
If Len(Trim(Me.Evaluation_date & "")) = 0 Then
DataIsMissing = True
End If
If Len(Trim(Me.[CR ID] & "")) = 0 Then
DataIsMissing = True
End If
'is all data entered?
If DataIsMissing Then
MsgBox (Prompt)
Else
DoCmd.Close
End If
End Sub

Explanation:

Code:

If Len(Trim(Me.[Date CR Performed]& "")) = 0 Then

So first concatenate a null string to the value in the control to get rid of possible NULLs
Then the Trim() removes leading and trailing spaces
Then use Len() to get the length of the value in the control (if there is a value)

All you need is to know if data is there or not. So if the data is missing, set the boolean variable "DataIsMissing" to TRUE .

Using this method, I don't have to worry about NULLs or leading/trailing spaces.

So to clarify, this code is tied to a button and when I click the button nothing happens.

As I have investigated further I realized that I was mistaken. All the Macros that are built in to Access work in the execute only file, but all the VBA code doesn't work. I think it might be a Network issue where the network is scanning it and thinks that it is unsafe and blocks the VBA code from running. Thank you for your time.

It sounds like the app needs to be run from a trusted location, or code needs to be enabled. Is there a bar under the ribbon when the app opens that says enable code or words to that effect? Or a warning?