Home > Software engineering >  Through the ACCESS VB ACCESS to EXCEL data to the database table is not successful, consult a warrio
Through the ACCESS VB ACCESS to EXCEL data to the database table is not successful, consult a warrio

Time:09-15

Want to create a button on the ACCESS form + VB program to obtain the specified directory EXCEL data to ACCESS data table, but have been unsuccessful, trouble under the instruction, thank you

Sub getInfosEs (sourcepath, Tname)
Dim xlApp As Excel. Application
Dim the rs As the ADODB library you
Set the rs=New ADODB. You
Rs. Open "Tname," CurrentProject. Connection, adOpenDynamic,
AdLockOptimistic
Dim adrs As ADODB. You
The Set of adrs=New ADODB. You
Adrs. Open "TempFiles," CurrentProject. Connection, adOpenDynamic adLockOptimistic,
Dim objFiles objmulu, intCount, strNames
IntCount=0
The Set objFiles=CreateObject (" Scripting. FileSystemObject ")
The Set objmulu=objFiles. GetFolder (sourcepath)
For Each strFile In objmulu. Files
IntCount=intCount + 1
If LCase (Right (strFile. Name, 3))="XLS" Then
The Set xlApp=CreateObject (" Excel. Application ")
XlApp. Workbooks. Open (sourcepath & amp; "/" & amp; StrFile. Name)
XlApp. Visible=False
XlApp. Sheets (1). Activate
With the rs
The AddNew
. Fields. The Item (0)=DCount (" * ", Tname) + 1
. Fields. The Item (1)=xlApp. Worksheets (1) Cells (2, 2)
. Fields. The Item (2)=xlApp. Worksheets (1) Cells (3, 2)
. The Update
End With
Rs. MoveNext
End the if
Next
MsgBox "ok"
End Sub

CodePudding user response:

Please go into more detail about, what do you want?

CodePudding user response:

Detailed is built on the ACCESS form, put a Command1 button on the form, click on the button, the related content within a specified directory all EXCEL spreadsheets all copied to ACCESS based on a form,

CodePudding user response:

If we know that Excel. Application
Why can't try operation access object way,
Access objects such as excel import and export of built-in functions than using ado method reads one again to about 100 times faster.

CodePudding user response:

In order to realize batch read automatically under the specified folder EXCEL content,

CodePudding user response:

Can say the Access and Excel form format?
Can send a sample of Access and Excel files?
  • Related