I used the answer from this post to export my queries to a text file so I could do a find/replace exercise:
Using VBA to export all ms access sql queries to text files
I inherited a database that has object names, banker1, banker2 etc., hard coded and I had to create extras. I exported all of my queries and replaced banker1 with the new names. So far so good.
Is it possible to reverse this process from the single text file generated and load the queries back into Access?
My previous method involved exporting the queries to single text files using Application.SaveAsText
, then looping through and doing my find/replace. The issue I encountered using this method is that the file is "formatted", possibly fixed width but not sure, such that some of the names were split across lines and therefore weren't detected by the find/replace. Loading them back in using Application.LoadFromText
worked perfectly except I still had to search through queries to find the names that hadn't changed.
Edit: Sample of queries requested.
BNK30-AddChargebacks INSERT INTO BNK30EntryTable ( Entry ) SELECT BNK30SelectChargebacks.Entry FROM BNK30SelectChargebacks WHERE (((BNK30SelectChargebacks.Amount)<>0));
BNK30-AddCredit INSERT INTO BNK30EntryTable ( Entry ) SELECT BNK30EntryQuery.Credit FROM BNK30EntryQuery WHERE (((BNK30EntryQuery.Amt)<>0));
In the above I would be doing a find/replace of BNK30 with BNK31 etc.
Edit 2:
Operation =3
Name ="BNK01SavedReserves"
Option =0
Where ="(((BNK01Select.Reference) Is Null Or (BNK01Select.Reference)=[forms]![BNK01Nav]!"
"[txtReference]) AND ((BNK01Select.Date) Is Null Or (BNK01Select.Date)=[forms]![B"
"NK01Form]![StartedTime]))"
Begin InputTables
Name ="BNK01Select"
End
Begin OutputColumns
Name ="AssignedTo"
The above is from my original method which works except where the BNK01 is split; just above the Begin InputTables line. Hence trying to switch to exporting the SQL as one big file.