I have a module I have created and I have no idea how to run it from a macro. I simply named it module1
I have a module I have created and I have no idea how to run it from a macro. I simply named it module1
You don't run the module, you run a function contained within the module (and they can't have the same name). The macro action would be RunCode.
Okay, what do I put in the "function Name" box? apparently I did not give it a name and Im not sure how to.
This is what I am trying to get to run. I pasted this into the module. General on drop down to the left and command0_click on the right one.
Private Sub Command0_Click()
Dim InputDir, ImportFile As String, tblName As String
InputDir = "C:\Import_Export\To_Import\"
ImportFile = Dir(InputDir & "\*.csv")
Do While Len(ImportFile) > 0
'tblName = Left(ImportFile, (InStr(1, ImportFile, ".") - 1)) 'This is to import each file into single tables.
tblName = "MidOhio BAC Import" 'This is to import all files into one table.
DoCmd.TransferText acImportDelim, , tblName, InputDir & ImportFile, True
ImportFile = Dir
Loop
End Sub
Let me explain what I am trying to do. I have several csv files that are going to be imported on a daily basis. Each files has a name that includes the date. I want to import each csv into its own table.
You have that in a standard module? Change the first and last lines to
Public Function ImportStuff()
End Function
You can change "ImportStuff" to whatever has meaning to you. Then in the Function Name argument of the macro put:
ImportStuff()
or whatever name you give it.
Thank You, that worked really well.
Happy to help.