在 MSAccess 中,我有一个带有按钮的掩码。当用户点击按钮时,表格中的数据将导出到 .txt 文件中:
Private Sub Command_Click()
Dim Rst As DAO.Recordset
Dim AField As DAO.Field
Dim TempStr As String
Dim FileNumber
FileNumber = FreeFile
Open "c:\table.txt" For Output As #FileNumber
Set Rst = CurrentDb.OpenRecordset("Tabella1", dbOpenForwardOnly)
Do While Not Rst.EOF
For Each AField In Rst.Fields
If (AField.Name <> "ID") Then
TempStr = TempStr & AField.value & " "
End If
Next
Print #FileNumber, Left(TempStr, Len(TempStr) - 1)
TempStr = ""
Rst.MoveNext
Loop
Rst.Close
Set Rst = Nothing
Close #FileNumber
End Sub
它可以工作,但我会通过允许用户选择导出数据的文件来显示“另存为...”对话框。
是否可以?