Home > Software engineering >  VBA prompt recognition database format
VBA prompt recognition database format

Time:09-19

Public Sub database creation ()
Dim CNN As ADODB. Connection 'Connection object variables
Dim mydata As String 'String variables
Mand Dim CMD As ADODB.Com
'Dim fs As New Scripting. FileSystemObject
Dim the fs As Object

Set the fs=CreateObject (" Scripting. FileSystemObject ")
'the Command object variables
Mydata=https://bbs.csdn.net/topics/ThisWorkbook.Path & \ "personnel management. The MDB"
'use of FSO object model to check whether there is a database file "personnel management. MDB
"If the fs. FileExists (mydata)=False Then
MsgBox "has not the personnel management database!" & "The system will automatically create personnel management database!" VbExclamation, "note"
The Set myaccess=CreateObject (" Access. Application ")
Myaccess. NewCurrentDatabase mydata
Myaccess. CloseCurrentDatabase
The Set myaccess=Nothing
End the If
Set the fs=Nothing
'establishment and "personnel management. MDB database connection
Set the CNN=New ADODB. Connection
With CNN
. The Provider="Microsoft jet. The oledb. 4.0"
. Open mydata
End With

After the operation in the open mydata tip database format unrecognized, for advice

CodePudding user response:

http://bbs.csdn.net/topics/392143402

CodePudding user response:

The personnel management. The MDB is with what version of the access to create? Suggest you read it in the oledb way, such and access version has nothing to do,

CodePudding user response:

Mydata string should be incorrect, CNN actual execution is a wrong connection,
As if mydata="HTTP://https://bbs.csdn.net/topics/Provider=Microsoft.Jet.OLEDB.4.0; Data Source="& amp; App. The Path & amp; "\ personnel management. MDB. Persist Security Info=False"
  •  Tags:  
  • VBA
  • Related