By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,940 Members | 614 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,940 IT Pros & Developers. It's quick & easy.

Run Time error 31599

100+
P: 443
I have a .csv file that I'm trying to import into my database, I have created a spec file and when I run it from the External Data tab an select Saved Imports everything runs great. Now when I try and run it from VBA using the following code
Expand|Select|Wrap|Line Numbers
  1. docmd.RunSavedImportExport HowReg
I get the run time error 31599 The specified name " cannot be set due to one of the following reasons: The specified name is not unique, The specified name is blank, The specified name does not follow object-naming rules.
I've checked through every record and find no " so I don't know why.
Any help would be appreciated.
Thanks
Apr 6 '17 #1

✓ answered by NeoPa

I almost missed the blindingly obvious too Tom :-D

HowReg, without any quotes, is simply a reference to a variable that contains nothing. You probably want :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.RunSavedImportExport("HowReg")
PS. I assume you're running this from the Immediate Pane. If you get that when running it from code then please slap your wrist for me and check out Require Variable Declaration.

Share this Question
Share on Google+
5 Replies


NeoPa
Expert Mod 15k+
P: 31,419
I almost missed the blindingly obvious too Tom :-D

HowReg, without any quotes, is simply a reference to a variable that contains nothing. You probably want :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.RunSavedImportExport("HowReg")
PS. I assume you're running this from the Immediate Pane. If you get that when running it from code then please slap your wrist for me and check out Require Variable Declaration.
Apr 6 '17 #2

100+
P: 443
I have the Option Explicit set and not sure how to declare the "HowReg" I've never tried to run a saved Import before.
Apr 7 '17 #3

NeoPa
Expert Mod 15k+
P: 31,419
Hi Tom.

There seems to be a little misunderstanding here. HowReg only requires declaration if it isn't enclosed in quotes ("). As a literal string this issue doesn't even come up.

If you have Option Explicit set in all your modules then that indicates you were probably running it from the Immediate Pane (Otherwise you'd have seen a quite different error message). In that case simply run the version I posted from there and all should work, assuming you have a properly-defined ImportExport Spec of that name of course.
Apr 7 '17 #4

100+
P: 443
Thanks for your help, everything is working just great.
Apr 7 '17 #5

NeoPa
Expert Mod 15k+
P: 31,419
Pleased to hear it Tom. Sometimes these types of problems allow us to get a better understanding as well as finding a solution.
Apr 8 '17 #6

Post your reply

Sign in to post your reply or Sign up for a free account.