Jump to content

'Nother MS Access question


MrDuke

Recommended Posts

Ok, I've got a program opening an Access database that auto-executes some code.

MSA lets you autorun any macro that't titled 'autoexec'.

 

Here's the goofy part:

 

If I keep it in that format (trying to open the autoexec macro at startup) I get an error msg saying 'cannot find the file xxxx.mdb where xxxx is the name of the database.

 

If I change the macro name from autoexec to anything else (defeating the autostart function), the initial program opens it fine and I have no errors.

 

Anyone have any comments/tips?

Link to comment
Share on other sites

Guest zerodamage
Guest zerodamage
Guest zerodamage
Guests

Sorry man, haven't touched MS Access in 5+ years. Work mostly with Mysql now (with lots of help).

Link to comment
Share on other sites

Ok, I've got a program opening an Access database that auto-executes some code.

MSA lets you autorun any macro that't titled 'autoexec'.

 

Here's the goofy part:

 

If I keep it in that format (trying to open the autoexec macro at startup) I get an error msg saying 'cannot find the file xxxx.mdb where xxxx is the name of the database.

 

If I change the macro name from autoexec to anything else (defeating the autostart function), the initial program opens it fine and I have no errors.

 

Anyone have any comments/tips?

Which version of MS Access are you using? What exactly is the autoexec macro doing? I design databases in MS Access all the time and I've never seen this behavior. One sure that that will fix some of the very screwy stuff that Access does, is to create a new blank database and import all of your macros, forms, tables, etc into it. That might fix it.

Link to comment
Share on other sites

Duke,

 

Make sure you have an explicit path in the autoexec file...I've noticed weird behavior with autoexec files in windows, sometimes it assumes a default path that is not what I would have though logical in any way.

 

Another option, perhaps, is to rename the macro to something else and have the autoexec macro run that macro (iirc you can nest macros).

 

Good luck!

Link to comment
Share on other sites

Make sure you have an explicit path in the autoexec file...I've noticed weird behavior with autoexec files in windows, sometimes it assumes a default path that is not what I would have though logical in any way.

His macro was called autoexec. I don't think he was dealing with any actual autoexec.bt files or anything.

 

Fox is right though, you can nest macros. What I do is use the autoexec macro to run a module, where I keep the code for the actions I want to take.

Link to comment
Share on other sites

Heh, son of a gun...I DID call it a file. I'm sorry, I was about to get really sarcastic and unfriendly...You know, like I often do :) Regardless, I meant macro. I also assumed you were using the macro to work between databases...just because of the xxxx.mdb. If you're not calling another db, then obviously paths are not an issue. Sorry, DSM!

 

Seriously, I have never had an autoexec component work flawlessly right off the bat, whether it was a batch file or macro. I like DSM's idea, because it just seems more...segmented. More friendly to the evil code reuse bandit.

Link to comment
Share on other sites

Heh, son of a gun...I DID call it a file.  I'm sorry, I was about to get really sarcastic and unfriendly...You know, like I often do :)

No harm no foul. Sarcastic and unfriendly, I can handle. It's stupidity I have a problem with. ;)

 

I forgot to mention that in my autoexec macro, all I have is one line, RunCode, and then I point it to the function that I want to run. A good way to test it is to create a function called test and then just have it do a msgbox "it works" or something like that. If you point to the function test from the RunCode command in your autoexec macro, then the message box should pop up when you open the database.

 

If you want to convert your macro to a module, just highlight it and do a File-Save As and in the dropdown, select module instead of macro. That's probably the easiest way. There's a good list of run command method constants here.

Edited by DogStarMan
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...