Results 1 to 11 of 11
  1. #1
    bbxrider is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2010
    Posts
    69

    autoexec to execute function at startup not working

    created a 'autoexec' macro, it does run at startup
    I thought it could invoke a vba function, that is what I need, to exec some code, but it can't find it or something
    see pics of autoexec, and error message
    and yes I have double/triple checked that the function is there
    I have 2 modules in the db and I just put the function for the autoexec in one of the modules
    so....
    I can run a vba function, yes?
    where to put the function?
    Attached Thumbnails Attached Thumbnails autoexec.2.png   autoexec.1.png  

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    the autoexec IS working , the function is not.
    see if the sharepoint connection to the table is working.
    or
    try a query instead of a function to delete the table (empty?)

    what does the function code do?

  3. #3
    bbxrider is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2010
    Posts
    69
    I need to search for a certain tables that might exist and delete them if any found
    there is a sharepoint connection is operational but the table in question is local in the db
    does it matter what module contains the function? the posts seem to imply the
    entire db, ie, all the modules would be searched for the function
    Code:
    Function delete_import_table() As String
       Set db = CurrentDb()
       'this is the table with universe all columns to populate from source tables
       For Each tdf In db.TableDefs
        ' iterate through all the potential source data tables
          If (tdf.Name Like "someTableName*") Then
             DoCmd.SetWarnings False
             DoCmd.Close acTable, tableName, acSaveYes
             DoCmd.DeleteObject acTable = acDefault, tdf.Name
            End If
                
       Next tdf 'next source table
    
    
    End Function

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    put a break at the top of the function. Manually run the autoexec. If it doesn't stop at the break, the function isn't running. It's possible it is but you're not aware of it because it isn't performing as expected. You could double check by creating a message box near the top of the function if you can't get a break to work. Knowing the function is being called is step 1.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    bbxrider is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2010
    Posts
    69
    see original post where I attached the error pic, with that message its pretty clear the function never gets invoked

    I think I post pretty clear what problem is and hope to get helpful, knowledgeable replies, if you don't like my terminology
    and don't understand the issue you don't have to post back
    just to count it out, I used "so" on 1 out of 12 lines posted
    but as I mention to above I'm just trying explain as clearly as possible with actual code using tags, and actual error messages
    did you see the code I have posted? did you see the screen shot of the macro? did you see the actual error message I posted?

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I won't darken your posts again if I can help it. Obviously you have a low tolerance for anyone who misses your point.
    As for my signature, it's there in every post, so I guess I could point out how you don't get everything you read either. You can have the last word as I'm unsubscribing to this one.

  7. #7
    bbxrider is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2010
    Posts
    69
    ok my bad, didn't realize it was signature, thought it was part of the actual reply

  8. #8
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    You must give the name of the function in macro with its parentheses: delete_import_table()
    If still doesn't work, try with variant as returned value of function.

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737

  10. #10
    bbxrider is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2010
    Posts
    69
    thanks accesstos, the ()'s was the trick, makes sense in retrospect all functions have the ()'s whether or not they are actually used to pass data, seems something like a fully qualified name/id
    this thread seemed to have died so I also posted in access world, I will wrap that up with this answer

  11. #11
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    You are welcome!
    Good continuing!

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

Similar Threads

  1. Access AutoExec Macro Cannot Find Function
    By JuanTooTree in forum Access
    Replies: 10
    Last Post: 06-08-2023, 10:10 AM
  2. CurrentDB.Execute insert working just once
    By krausr79 in forum Access
    Replies: 4
    Last Post: 10-07-2015, 12:04 PM
  3. Replies: 2
    Last Post: 08-19-2013, 01:14 PM
  4. Replies: 3
    Last Post: 01-08-2013, 11:51 AM
  5. Replies: 3
    Last Post: 12-27-2012, 04:20 PM

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