I am trying to call a Function in the Sub of my code. Can someone tell me what I'm doing wrong? Below is the code I am using
Rich (BB code):
Option Compare Database
Public Sub Command0_Click()
Dim MyFolder As String
Dim MyFile As String
Dim MyFolder2 As String
Dim DQ As String
Dim MyData As String
Dim myQueryName As String
Dim myExportFileName As String
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from Import_Data"
MyFolder2 = "S:\zCorey\TDD File Cleanup\Sample Files\New Version"
MyFile = Dir(MyFolder2 & "\*.txt")
Do While MyFile <> ""
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from Import_Data"
DoCmd.TransferText acImportDelim, "Import Specification", "Import_Data", MyFile, True
Call CODEW
'DoCmd.TransferText acExportDelim, "S:\zCorey\TDD File Cleanup\Sample Files\New Version" & [MyFile], False, "", 0
DoCmd.TransferText transferType:=acExportDelim, SpecificationName:="Export Specification", TableName:="Import_Data", _
FileName:="S:\zCorey\TDD File Cleanup\Sample Files\New Version" & [MyFile], hasfieldnames:=True
DoCmd.SetWarnings False
MyFile = Dir
Loop
End Sub
Function CODEW(Character As String, Optional Unicode_value As Boolean = True, Optional Exact_functionality As Boolean = False) As Variant
' Exact Functionality returns exact Unicode for characters as AscW() does
' rather than Windows characters as Asc() does
Dim Characters As String
Dim i As Long
If Exact_functionality Then
CODEW = AscW(Character)
If Unicode_value Then CODEW = "U" & Hex(CODEW)
Exit Function
End If
For i = 128 To 159 'where non-compliant
Characters = Characters & Chr(i)
Next i
If InStr(1, Characters, Left$(Character, 1), vbBinaryCompare) Then
CODEW = Asc(Character)
Else
CODEW = AscW(Character)
End If
If Unicode_value Then CODEW = "U" & Hex(CODEW)
End Function
Last edited by a moderator: