-
WSPaulK
AskWoody LoungerI think it is the “$” in the table name that is throwing things off. I tried the statement with the $ and without it (had to rename the table) and it worked without but I got a similar error that you did with it. So, try renaming the table and editing the code and try it that way and see if it works.
-
WSPaulK
AskWoody LoungerI believe the problem lies in your statement:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, strFilename, “c:HistoryArchivesstrFilename.xls”, True
The argument strFileName should be the name of the table you are exporting as it exists in the database without any date concatenation. The next argument is where you want the date to concatenate with the table name. Something like this:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, “tblNameOfTableToExport”, “c:HistoryArchivestblNameOfTableToExport” & format(Date(),”mddyy”) & “.xls”, True
You can do the concatenation on separate lines but don’t confuse the name of the table to export with the destination file name. They should be two separate objects or variables.
BTW, I tried exporting a table using the same method and intentionally supplying an invalid table name and got a similar error message so that’s why I’m focusing on the transferspreadshet method.
-
WSPaulK
AskWoody LoungerThe samples are on my copy of the Office97 Pro CD.
-
WSPaulK
AskWoody LoungerOne idea that popped into my head was using the tag property to identify each unbound control. This way you could loop through the forms’ controls collection and test the tag property for a certain value – “UB”? – and then do your writes. I’m sure there are other ways to approach this as others may suggest. It might be helpful to know the bigger picture, for instance why the need exists to write these values to another table?
-
WSPaulK
AskWoody Lounger[indent]
What seems so obvious at the time becomes more and more obscure as time passes, and it makes it easier for someone else to pick up and use.
[/indent]
How many times have I written something only to come back a month later and scratch my head.
I particularly like where you comment the end ifs, end selects and even end function with the head line. I’ve never seen that done before and while some may consider it overkill I can see where it would come in handy in some of the more complicated logical routines.
-
WSPaulK
AskWoody LoungerHard to tell from here what exactly is causing the breakdown. I’d be curious to hear what the actual flow looks like if you put in a break point and went through the code line by line. That might help give us a clue where to focus our attention.
-
WSPaulK
AskWoody LoungerI like that even better!
-
WSPaulK
AskWoody LoungerI would hesitate storing this sort of thing in a table as it can usually be calculated in a query. Is there a date associated with each record? If so you could use the year function or right function to return the 2 digit year portion of the date along with a combination of padded zeroes and an autonumber field. Post back if you need help with the expression.
-
WSPaulK
AskWoody LoungerIs there a name property for that object…?
Set f = fs.GetFile(fs.GetFileName(.FoundFiles(i).Name))
-
WSPaulK
AskWoody LoungerGlad to help, Roberta! And I must say it’s nice to connect a face with the name after seeing just your name on the other forum (ElementK).
What’s the error…maybe I can help with that too.
-
WSPaulK
AskWoody LoungerTry this:
strFileName = “PH_Exp$” & Format(strDate, “mddyy”)
Instead of:
strFileName = “PH_Exp$” & strDate
-
WSPaulK
AskWoody LoungerDon’t give up yet. I was able to create a field in a table related to an employee table which displays the name in datasheet view from the first column but stores the employee id in the table from the second column. What may be tripping you up is that even though the id is being stored in the table you still see the name displayed in datasheet view. You can test if the id is being stored by opening a new report in design view and base it on the table where the name is displayed but the id is stored. Add a textbox – not a combobox – to the report and set it’s control source property to the name field. Then preview the report and you should see the id displayed on the report and not the name.
-
WSPaulK
AskWoody LoungerGlad it worked for you. For future reference you can export a query as well as a table which should give you the ability to sort the table data how you want.
-
WSPaulK
AskWoody LoungerTry setting the control source properties for the report controls to your form controls. Use the expression builder if you’re not sure about the correct syntax. It should be something like this:
=[Forms]![frmTest01]![txtUPCODE]
This should work with your code in the format event.
-
WSPaulK
AskWoody LoungerI would have to agree with Charlotte and ask why are you putting so much emphasis on sorting the table?
Having said that try creating the autonumber field in the new table before appending the sorted records to the new table.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Marriage Counseling – Manages To Do It Save Our Marriage? (Awaiting moderation)
by
lynwoodspellman
56 minutes ago -
Where’s the cache today?
by
Up2you2
49 minutes ago -
Ascension says recent data breach affects over 430,000 patients
by
Nibbled To Death By Ducks
7 hours, 55 minutes ago -
Nintendo Switch 2 has a remote killing switch
by
Alex5723
8 hours, 15 minutes ago -
Blocking Search (on task bar) from going to web
by
HenryW
1 hour, 30 minutes ago -
Windows 10: Microsoft 365 Apps will be supported up to Oct. 10 2028
by
Alex5723
18 hours, 3 minutes ago -
Add or Remove “Ask Copilot” Context Menu in Windows 11 and 10
by
Alex5723
18 hours, 10 minutes ago -
regarding april update and may update
by
heybengbeng
19 hours, 39 minutes ago -
MS Passkey
by
pmruzicka
24 minutes ago -
Can’t make Opera my default browser
by
bmeacham
1 day, 3 hours ago -
*Some settings are managed by your organization
by
rlowe44
14 hours, 3 minutes ago -
Formatting of “Forward”ed e-mails
by
Scott Mills
1 day, 2 hours ago -
SmartSwitch PC Updates will only be supported through the MS Store Going Forward
by
PL1
1 day, 21 hours ago -
CISA warns of hackers targeting critical oil infrastructure
by
Nibbled To Death By Ducks
2 days, 6 hours ago -
AI slop
by
Susan Bradley
51 minutes ago -
Chrome : Using AI with Enhanced Protection mode
by
Alex5723
2 days, 8 hours ago -
Two blank icons
by
CR2
19 hours, 56 minutes ago -
Documents, Pictures, Desktop on OneDrive in Windows 11
by
ThePhoenix
2 days, 17 hours ago -
End of 10
by
Alex5723
2 days, 19 hours ago -
Single account cannot access printer’s automatic duplex functionality
by
Bruce
1 day, 17 hours ago -
test post
by
gtd12345
3 days, 1 hour ago -
Privacy and the Real ID
by
Susan Bradley
2 days, 15 hours ago -
MS-DEFCON 2: Deferring that upgrade
by
Susan Bradley
18 hours, 16 minutes ago -
Cant log on to oldergeeks.Com
by
WSJonharnew
3 days, 6 hours ago -
Upgrading from Win 10
by
WSjcgc50
1 day, 17 hours ago -
USB webcam / microphone missing after KB5050009 update
by
WSlloydkuhnle
1 day, 21 hours ago -
TeleMessage, a modified Signal clone used by US government has been hacked
by
Alex5723
3 days, 21 hours ago -
The story of Windows Longhorn
by
Cybertooth
3 days, 9 hours ago -
Red x next to folder on OneDrive iPadOS
by
dmt_3904
3 days, 23 hours ago -
Are manuals extinct?
by
Susan Bradley
1 day ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.