Results 1 to 11 of 11

autoexec to execute function at startup not working

  1. #1
    bbxrider is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2010
    Posts
    67

    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 online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    7,147
    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
    67
    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
    4,849
    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.
    - "doesn't work" is no help. Post err msgs and where.
    - Use code tags for code/sql. Implement changes in copies of your database.
    So, like, why do you, like, start every sentence with, like, "so"?

  5. #5
    bbxrider is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2010
    Posts
    67
    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
    4,849
    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
    67
    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 Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    55
    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
    4,849

  10. #10
    bbxrider is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2010
    Posts
    67
    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 Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    55
    You are welcome!
    Good continuing!

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

Similar Threads

  1. CurrentDB.Execute insert working just once
    By krausr79 in forum Access
    Replies: 4
    Last Post: 10-07-2015, 11:04 AM
  2. Replies: 2
    Last Post: 08-19-2013, 12:14 PM
  3. Access AutoExec Macro Cannot Find Function
    By JuanTooTree in forum Access
    Replies: 3
    Last Post: 03-14-2013, 07:52 AM
  4. Replies: 3
    Last Post: 01-08-2013, 10:51 AM
  5. Replies: 3
    Last Post: 12-27-2012, 03: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
  •  
Tech Forums: Microsoft Office Forums