【发布时间】:2017-06-08 07:55:10
【问题描述】:
我收到 ByRef 参数类型不匹配。以下代码(特别是 varFile)为错误突出显示:
Call InsertCMS_Reports_2ndSave(varFile)
这是我的表格:
选项比较数据库
'Private Sub Command0_Click()
Private Sub cmdFileDialog_Click()
'Requires reference to Microsoft Office 12.0 Object Library.
Dim fDialog As Office.FileDialog
Dim varFile As Variant
'Clear listbox contents.
'Me.FileList.RowSource = ""
'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make multiple selections in dialog box.
.AllowMultiSelect = True
'Set the title of the dialog box.
.Title = "Please select one or more files"
.InitialFileName = "C:\Users\ABCDEF\Desktop\CCCEEe CMS Reports"
'Clear out the current filters, and add our own.
.Filters.Clear
'.Filters.Add "Access Databases", "*.MDB; *.ACCDB"
.Filters.Add "Access Projects", "*.txt"
'.Filters.Add "All Files", "*.*"
'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = True Then
'Loop through each file selected and add it to the list box.
For Each varFile In .SelectedItems
' Me.FileList.AddItem varFile
Call InsertCMS_Reports_2ndSave(varFile)
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub
模块代码:
Function InsertCMS_Reports_2ndSave(FileName As String)
'DoCmd.DeleteObject CopyOfCOMPRPT_CE, "CMS_Reports_2ndSave"
DoCmd.TransferText acImportFixed, "CMS_Reports_Import", _
"CMS_Reports_Import", "C:\Users\A088982\Desktop\January CMS reports for Centene\FileName"
CurrentDb.Execute "UPDATE CopyOfCOMPRPT_CE SET FileName = 'HLTH_COMPRPT_1701011028174_h0062.txt' WHERE FileName is NULL", dbFailOnError
End Function
【问题讨论】:
-
那不是 VB.NET 代码;访问-vba 不是 VB.NET。请修复标签(如果确实如此,可能添加 VB6 - 标签上的文字提供指导)
-
@Plutonix 已修复,谢谢!
-
InsertCMS_Reports_2ndSave()声明了哪些参数? -
@AlexK 嗨,Alex,这是我保存的导入规范
-
@AlexK 我最终将 FileName As String 更改为 FileName as Variant(感谢您的提示),但我没有看到,我将运行我的表单以确保其正常。跨度>
标签: ms-access vba ms-access-2010