Active Oldest Votes. Connection" ' Open Connection objConnection. Recordset" objRecordset. Improve this answer. Thank you! I think I tried the direct ADO connection string already and got the same error message. But I'll try what you said, it does look simpler than my other scripts.
If all else fails I'll make an ASP. NET console app to do it. But that might have the same connection string issues. Please post your updated code if you still run into problems! As far as connection string, perhaps you can simply check the file extension before connecting and adjust the Provider.
If so, have you installed the [ADO 2. Connection" oConn. Give as much detail as possible, explain what you are trying to accomplish, and even the why you are trying to do it and people will offer you solutions to your question.
I have an awful old MS Access DB that needs to be running on my server, but sometimes it chokes, so I needed a nice script to kill it and restart it. Thank you for this code. Would this be used for a Access db? Yes, it should work without issue.
I created it back in , so that would mean it was working with Access and beyond. Where exactly do you put this code? I work for a company and have been trying to use access to help with our data.
Create a new txt file using Notepad. Save it. Go and rename the txt file from YourFileName. You now have a vbscript. You can continue to edit it with any standard text editor. It will automatically be set. You could also just use a. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Script to open Access database, run macro, and persist Access instance Ask Question. Asked 8 years, 1 month ago. Active 5 years, 7 months ago. Viewed 60k times. The problems I see are that regardless of whether the code is stored in a VBScript file or run from within the VBA of the database, the user, to trigger this, will need to have the database open.
The very first thing the user sees when they open the database is a front end that manages the databases they can use. When they click on the one they want it actually opens a whole new database.
So technically, when they open the database, the one to be copied is not open yet. Also, copying to and from the network, these databases on the network aren't opened as we put a copy, not a shortcut on thier desktop. Does this make sense? That makes sense. I expect you can handle running the VBScript using the Shell command then.
You could also handle file manipulation to a fair extent from within VBA of course, but if you already have the VBScript files available then I'd use Shell to invoke them. So next question, where do I implement Shell? Be aware though - Shell runs Asynchronously. This means the following succeeding line of VBA code will continue to execute as soon as the Shell command has been invoked. It will NOT wait for your script to finish before continuing. I'm currently working on a routine which will work as an equivalent to Shell but with a wait built in.
It involves Windows API function calls so it's a little cumbersome, but if you're interested just let me know. To be sure, it's generally only needed when you want to trigger something to run AFTER your script has completed or you want to stop the operator from doing anything else until after it's completed.
0コメント