How to write to a text file in Access

dave8

Active Member
Joined
Jul 8, 2007
Messages
275
I want to be able to create a text file in Access and write a message when an macro query is completed.
Is there a way to do something like this?

For example:

Query1
Do something
....
end query2
"Query1 has completed" < ----- This statement gets written to Text file

Query2
Do somehting
....
end query2
"Query2 has completed" <-------- This statement gets appended to Text file
Query3...
....
 
I'm trying to add the "Set Warnings ON/Off" but I can't find this statement in the AutoExec.
The dropdown list only has SetDisplayedCategories to SetTempVar. How do I add the Set Warnings ON in
the AutoExec?
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Make sure you have selected "Show All Actions" on macro design Actions tab.
 
Upvote 0
Is there a way when writing to the log file to keep the file open until the entire routine finishes, rather than opening and closing the file every time an error occurs?
 
Upvote 0
Not sure I understand why you've asked that. As written, one error writes to the file and exits the function so the entire routine can't finish. You have modified the code to do something different? I covered this point in post 10, I'd say, which was to gather all errors and write once. Not sure, but I don't think you can write to the file when it's open, but that would be easy enough to test if that's your preference. To do that, move f.Close to just before exitHere. However, I believe you'd generate an error if f had not been already set (assuming that's still being done in the error handler), so just before f.Close I'd write On Error Resume Next. This error (if it occurs) would be ignored and allow you to exit. If you need further help, post the code you have so I can see how/if you modified it.
 
Upvote 0
Yes, I was not thinking the logic correctly. I want to thank you very much for helping me understand Access. I really appreciate your help. :)
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,576
Members
448,972
Latest member
Shantanu2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top