"Invalid argument" Error
testname$ = InputBox$("What do you want to name your test?")
Dim db As Database
Dim dbname As String
dbname$ = CurDir$ + "\" + testname$
Set db = CreateDatabase(dbname$, DB_LANG_GENERAL, DB_VERSION10)
Now, this is pretty much straight out of the book, and it's on the last line that I'm getting hung. Any ideas?
Thanks in advance...
From: Tom Davidson (Apache)
Email: Apache@Cupid.com
I suspect what is actually happening is that you do not have Option Explicit set on (have a look at 'Require Variable Declaration' in Options|Environment) which means that VB will let you get away with referencing variables that you have not declared and will simply create them as needed. If you do not have DB_LANG_GENERAL declared VB will create the variable as a variant with a default string value of "". As far as JET is concerned this is not a valid set of settings and there you have the "invalid argument" error.
Do yourself a favour and avoid troubles like this in the future by setting Option Explicit on. Then make sure that the declaration for DB_LANG_GENERAL is included in your project (you may wish to add DATACONS.TXT to your project). You should then find that the code will run without a problem.
By the way, you may wish to consider removing the last parameter so that you produce a Version 1.1 database instead of a version 1.0 database. If you download a file called comlyr.exe (725 KB) this will allow you to produce Version 2.0 databases by default.
Enjoy.