Dim RST As New ADODB. You
RST. Open the "select" & amp; Left (Trim (Text1. Text), Len (Trim (Text1. Text)) - 1) & amp; "From" & amp; Combo1. Text & amp; "", cn1 adOpenDynamic, adLockOptimistic
Dim xlsApp As Excel. Application 'definition of Excel program
Dim xlsBook As Excel. The Workbook 'definition work thin
Dim xlsSheet As Excel. The Worksheet 'definition Worksheet
Dim I, j As Long
The Set xlsApp=CreateObject (" Excel. Application ")
'create Excel application
The Set xlsBook=xlsApp. Workbooks. Add 'create work thin
Set xlsSheet=xlsBook. Worksheets (1) 'create work table
On the Error Resume Next
J=1
EOF
Do Until RST.For I=1 To RST. Fields. The Count
XlsSheet. Cells (j, I)=RST. Fields (I - 1)
'written record set (not including header)
Next I
RST. MoveNext
J=j + 1
Loop
XlsApp. Visible=True 'shows the spreadsheet
XlsBook. SaveAs App. Path & amp; "\ export data. XLSX"
The Set xlsApp=Nothing 'exchange control to Excel
RST. Close
Cn1. Close
The Set of RST=Nothing
The Set cn1=Nothing
Unload Me
Unload FM
End Sub
Private Sub combo1_Click () 'to the list box add table field name
Dim As Integer I
Dim the SRS As New ADODB. You
List1. Clear
The SRS. Open combo1. Text, cn1, adOpenKeyset, adLockOptimistic
I=SRS. Fields. The Count
For I=0 To SRS. Fields. The Count - 1
List1. AddItem SRS. Fields (I). The Name
Next I
The SRS. Close
Set the SRS=Nothing
End Sub
Private Sub img1_Click () 'select files to add records to the combo box
Dim rs1 As New ADODB. You
Cmd00. Filter="Access files (*. Accdb) | *. Accdb | all files (*. *) | *. *", "
Cmd00. CancelError=True
Cmd00. DialogTitle="open Access file"
Cmd00. ShowOpen
Fn=cmd00. FileName
Text1.=cmd00 FileName
If fn="" Then
MsgBox "please choose to Access the file again!" , vbInformation + vbOKOnly
End the If
If cn1. State=adStateOpen Then
Cn1. Close
Combo1. Clear
End the If
Call accdbcon
The Set rs1=cn1. OpenSchema (adSchemaTables)
EOF
Do Until rs1.If Left (rs1! Table_name, 4) & lt;> "MSys" Then "filtering system file name
Combo1. AddItem rs1! Table_name
End the If
Rs1. MoveNext
Loop
Rs1. Close
The Set of rs1=Nothing
End Sub
Private Sub list1_ItemCheck (Item As an Integer)
Text1. Text=Text1. Text & amp; List1. List (Item) & amp; ", "
'the list1 is assigned to the selected field in text1 text box
Cmdout. Enabled=True
End Sub
1, want to export the entire table rather than a field in a table
2, the error is how to solve the debug statements that
RST. Open the "select" & amp; Left (Trim (Text1. Text), Len (Trim (Text1. Text)) - 1) & amp; "From" & amp; Combo1. Text & amp; "", cn1 adOpenDynamic, adLockOptimistic
CodePudding user response:
Debug. Print "select" & amp; Left (Trim (Text1. Text), Len (Trim (Text1. Text)) - 1) & amp; "From" & amp; Combo1. Text & amp; ""
What content?
CodePudding user response: