Create Database Run Time 3001, Invalid Argument

mrmmickle1

Well-known Member
Joined
May 11, 2012
Messages
2,461
I am trying to create a database and then create a few tables in the database. I am having trouble creating the database. This is what I have so far:

Code:
Sub CreatePendingLogDB()
    
  [COLOR=#0000ff]  Dim[/COLOR] TableArr [COLOR=#0000ff]As[/COLOR] Variant
  [COLOR=#0000ff]  Dim[/COLOR] accessApp [COLOR=#0000ff]As [/COLOR]Access.Application
    [COLOR=#0000ff]Dim [/COLOR]DBFileString [COLOR=#0000ff]As String[/COLOR]
    
 [COLOR=#0000ff]   Set[/COLOR] accessApp = [COLOR=#0000ff]New [/COLOR]Access.Application
    DBFileString = "C:\Users\" & Environ("UserName") & "\Desktop\PendingLog" & Format(Date, "MM.DD.YYYY") & ".accdb"
[COLOR=#008000]    'Get Stuck Here Run Time 3001 Invalid Argument[/COLOR]
[COLOR=#ff0000]    accessApp.DBEngine.CreateDatabase DBFileString, dbLangGeneral[/COLOR]

It will not run on the red line of code. Any pointers or help would be appreciated. Just starting to get into Access VBA...
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Do you have a reference set to a DAO library? If not, dbLangGeneral has no meaning and won't be a valid parameter. Also, if you do use the DAO reference, you don't need to automate Access at all:
Code:
Sub CreatePendingLogDB()
    
    Dim TableArr As Variant
    Dim DBFileString As String
    
    DBFileString = "C:\Users\" & Environ("UserName") & "\Desktop\PendingLog" & Format(Date, "MM.DD.YYYY") & ".accdb"

    DAO.DBEngine.CreateDatabase DBFileString, dbLangGeneral
 
Upvote 0
RoryA,

Thanks for the help. Unfortunately I am not able to select this reference at the moment. I am at my work computer and when I try to select the reference for Microsoft DAO 3.6 Object Library it tells me Error in Loading DLL. I found the actual file in this directory on my computer:

'C:\Program Files (x86)\Common Files\Microsft Shared\DAO\DAO360.dll'

However, when I try to browse for the reference in the VBE to this location it does not let me select the file. Does this mean that I need to get my company's IT Dept. to Register this DLL file using the Registry Editor?

Is there another way to go about Creating a Database that doesn't involve DAO? Or should I just try to channel the information into an existing database (to avoid having to create a fresh one)?
 
Upvote 0
Try referencing the Microsoft Office 14.0 Access Database Engine library instead.
 
Upvote 0
RoryA,

I followed your instructions and the code executes properly now! Thank you for the help. I really appreciate it :)
 
Upvote 0
Glad to help. :)
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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