Macro in Access

billykiller05

New Member
Joined
Oct 17, 2007
Messages
23
I am new to access and I would like to write a macro to run a query. I receive a file each month so I need to be able to change the table for which the query is ran. I need some help getting started.
 
Last edited:
I am using 2b. I got my first text file into my table with the period column added and ran the update query to add the date. However once I import the next text file into the same table I can not get the update query to work to add the date to the blank records in the Period column. My last post was worded incorrectly.
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Do you have Criteria on the Update Query to only look at records where the Date field is blank?

What might help is to post the SQL code of your Update Query. To do this, change to SQL View in the Query, and copy and paste the resulting code here.
 
Upvote 0
This is the expression I used from the build menu:
UPDATE TopAccounts SET TopAccounts.Period = #5/1/2008#
WHERE (((TopAccounts.Period)=""));
 
Upvote 0
If "Period" is formatted as a date field, it may not like your criteria. Try this:
Code:
UPDATE TopAccounts SET TopAccounts.Period = #5/1/2008#
WHERE (((TopAccounts.Period) Is Null));
 
Upvote 0
I have my macro setup to OutputTo but I get an error message. It say "There are too many rows to output, based on the limitation specified by the output format or by Microsoft Access". There are about 25,000 rows in my query so I now Excel can hold it. Is there any way to change Access or Excel to not get this error message? Or is there another macro I can use to get the query into Excel?
 
Upvote 0
I believe the OutputTo option on query has limitations (I never use it myself).

You are better off to use the TransferSpreadsheet Macro action.
 
Upvote 0
Transfer Type: Export
Spreadsheet Type: Microsoft Excel 8-10
Table Name: Enter the name of your query here (kind of misleading, doesn't have to be a table, can be a query)
File Name: Name file path and name you want to export the file to
Has Field Names: Select Yes if you want to export field names in the first row of your file
Range: Leave blank
 
Upvote 0
That works great. Thanks again. Is there a way to add the date I use to run my query to the filename each time so the spreadsheet would be TopAccounts 05-2008.xls or TopAccounts 04-2008 depending on the date used?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,618
Messages
6,120,544
Members
448,970
Latest member
kennimack

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