Papa_Bear1
Member
- Local time
- , 22:53
- Joined
- Feb 28, 2020
- Messages
- 150
Hi,
I'm trying to build a solution that can pull the pieces out of any specified Access DB (e.g., SQL And VBA for version control code management etc.) and then also the ability to perform the reverse of that, creating an Access DB from those pieces as well (as much as possible.)
I'm encountering a surprising number of hurdles trying to do this. I expected it to be pretty much - cycle through the objects, export the code, then on the reverse, create the objects and populate the pieces with SQL or code. But no - each component/type seems to come with its own set of requirements, with one way to 'export' module code, but another way to 'export' query SQL etc. For example, it seems the *only* way to export VBA code is by establishing a reference to the external DB. This has caused a bit of grief for me in various ways - not the least of which being - when things go wrong - it never enables the "Debug" option. So I have to shut things down and start over - really slowing down development.
My current predicament is that I'm getting an error trying to use the following code to create a module in a newly created external DB:
I get
"Run-time error '5':
Invalid procedure call or argument
With ONLY the "End" and "Help" buttons enabled - so I cannot debug as usual.
Also, when I do any Reference coding - and try to walk in debug mode - it tells me I can't.
I then tried to achieve this - without "import" by manually creating the module and stuffing the code in it, like the following:
- but the code I had saved was an 'export' which had the header stuff in it. So, now I will have to strip out that text. Good grief.
So, I then decided to shift gears and see if I can do ALL of this just by using a database object (and not a reference) - but on the 'export' side of it, I've been hunting for the actual VBA itself in those objects and it seems the VBA is just not there. The module and its name and properties are all there - but not the VBA itself.
Very frustrating for this to need to be so circuitous. I must be missing something obvious.
I've seen references here about tools developed by members to provide exactly this capability (I think it was @isladogs ?), and I may end up trying that, but I really didn't want to embark on using someone else's code just yet. Part of this is learning, and I also have found that I can rarely use someone else's code as it never quite fits my requirements. But again - I may go down that road - once I've pulled out my remaining hair. Ha.
Is there a *consistent* way to cycle through Access objects for export/saving and import/restoring from/to an Access DB?
And btw - I'm only really trying to do this for SQL/code behind queries, reports, and forms, along with creation of DDL and data save/restore for a more 'base-level' reconstituting of the tables etc. I've been wondering where Access hides the actual form design info, but that is a bridge too far for me at this point - as I'm running into problems just trying to save/restore code. At some point, I suppose the back-ups of the Access files themselves serve the goal of restoration. But this exercise is meant to support interfacing with code management software - which is much better behaved with text files. So, I'm trying to see what I can do in that vein.
thanks for any help/ideas!
I'm trying to build a solution that can pull the pieces out of any specified Access DB (e.g., SQL And VBA for version control code management etc.) and then also the ability to perform the reverse of that, creating an Access DB from those pieces as well (as much as possible.)
I'm encountering a surprising number of hurdles trying to do this. I expected it to be pretty much - cycle through the objects, export the code, then on the reverse, create the objects and populate the pieces with SQL or code. But no - each component/type seems to come with its own set of requirements, with one way to 'export' module code, but another way to 'export' query SQL etc. For example, it seems the *only* way to export VBA code is by establishing a reference to the external DB. This has caused a bit of grief for me in various ways - not the least of which being - when things go wrong - it never enables the "Debug" option. So I have to shut things down and start over - really slowing down development.
My current predicament is that I'm getting an error trying to use the following code to create a module in a newly created external DB:
Code:
prjTarget.VBComponents.Import strImportPathFile
I get
"Run-time error '5':
Invalid procedure call or argument
With ONLY the "End" and "Help" buttons enabled - so I cannot debug as usual.
Also, when I do any Reference coding - and try to walk in debug mode - it tells me I can't.
I then tried to achieve this - without "import" by manually creating the module and stuffing the code in it, like the following:
Code:
vbcProc.CodeModule.AddFromString strVBA
- but the code I had saved was an 'export' which had the header stuff in it. So, now I will have to strip out that text. Good grief.
So, I then decided to shift gears and see if I can do ALL of this just by using a database object (and not a reference) - but on the 'export' side of it, I've been hunting for the actual VBA itself in those objects and it seems the VBA is just not there. The module and its name and properties are all there - but not the VBA itself.
Very frustrating for this to need to be so circuitous. I must be missing something obvious.
I've seen references here about tools developed by members to provide exactly this capability (I think it was @isladogs ?), and I may end up trying that, but I really didn't want to embark on using someone else's code just yet. Part of this is learning, and I also have found that I can rarely use someone else's code as it never quite fits my requirements. But again - I may go down that road - once I've pulled out my remaining hair. Ha.
Is there a *consistent* way to cycle through Access objects for export/saving and import/restoring from/to an Access DB?
And btw - I'm only really trying to do this for SQL/code behind queries, reports, and forms, along with creation of DDL and data save/restore for a more 'base-level' reconstituting of the tables etc. I've been wondering where Access hides the actual form design info, but that is a bridge too far for me at this point - as I'm running into problems just trying to save/restore code. At some point, I suppose the back-ups of the Access files themselves serve the goal of restoration. But this exercise is meant to support interfacing with code management software - which is much better behaved with text files. So, I'm trying to see what I can do in that vein.
thanks for any help/ideas!