Results 1 to 7 of 7
  1. #1
    jspencer is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    May 2020
    Posts
    3

    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.

    Any ideas of why this might be happening.

    I attached the code I am using below.

    Thanks!!!
    Attached Files Attached Files

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,212
    What exactly does "doesn't work" mean? Do you get an error? If so, what is it?

    This line needs the field for the second test, as you did in the If:

    ElseIf total = 0 Or 7 Then

    In fact, you probably should just have an Else.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    8,732
    Even though Paul solved your problem, I rewrote your code.

    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.
    HTH
    -----
    Steve
    --------------------------------
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)

  4. #4
    jspencer is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    May 2020
    Posts
    3
    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.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,212
    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?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    jspencer is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    May 2020
    Posts
    3
    This is the warning I get every time it is opened. Thanks
    Attached Thumbnails Attached Thumbnails NCRWarning.PNG  

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,212
    I assume you click on Open? I would expect that to enable code. You might try adding the folder the file is stored in to Trusted Locations.

    https://support.office.com/en-us/art...3-4E7C67147FB4

    If they have the runtime version, there's a registry setting to add it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. autoexec to execute function at startup not working
    By bbxrider in forum Programming
    Replies: 10
    Last Post: 01-12-2019, 05:50 PM
  2. Can't execute make table query from a Module
    By MisterPepe in forum Modules
    Replies: 10
    Last Post: 04-13-2018, 01:31 PM
  3. Can't Remove MsgBox without module not working
    By cm-net in forum Programming
    Replies: 1
    Last Post: 01-20-2018, 07:49 AM
  4. CurrentDB.Execute insert working just once
    By krausr79 in forum Access
    Replies: 4
    Last Post: 10-07-2015, 12:04 PM
  5. Execute a module?
    By philip.mccollum in forum Access
    Replies: 1
    Last Post: 07-08-2015, 05:57 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums