2017-01-23 2 views
0

ByRef 인수 형식이 일치하지 않습니다. 다음 코드 (varFile는 specificaly) 오류에 대한 강조 :ByRef 인수 형식 불일치 - VB 액세스

옵션은 데이터베이스 비교

'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 
+1

그게 전부하지 VB.NET 코드; access-vba IsNot VB.NET. 태그를 수정하십시오 (어쩌면 VB6을 추가하십시오. 실제로 해당되는 경우 - 태그의 단어가 지침을 제공합니다). – Plutonix

+0

@Plutonix가 수정되었습니다. 감사합니다! – KKP

+0

'InsertCMS_Reports_2ndSave()'는 어떤 인자를 선언합니까? –

답변

0

여기에

Call InsertCMS_Reports_2ndSave(varFile) 

은 내 양식입니다 이 오류가 발생하는 이유는 varFile을 변형으로 지정했기 때문입니다. howe ver 함수가 문자열을 기다리고 있습니다. 대신이 시도 :

Function InsertCMS_Reports_2ndSave(FileName)