Finding Syntax in VB4.0
Function impcell()
Dim yest$, f$
yest$ = Format(Now() - 1, "yymmdd")
f$ = Mid$(yest$, 3, 4) & Mid$(yest$, 1, 2)
DoCmd.TransferText acImportDelim, "Cell Results Import Specification",
"cell", "F:\DBMS\RAWDATA\PARSED\cr" & f$ & ".csv"
End Function
The rest of the code just specifies the name of the file.
I've looked for the Do.Cmd syntax in VB 4.0, but can't find it. Does it exist? If not, can I call this function from VB 4.0 and run it on a machine that has VB 4.0 but not Access?
From: Jeff Motter
Email: jmotter@fgi.net
However, VB has some very cool text file handling functions and you can fairly easily write something that will do the same job. The first step is to make yourself familiar with the VB Open statement used to open files for various sorts of access. Once you have your file open you can read it in using whatever method you choose to code. As an example your code will likely end up looking something like this:
Dim hFile as Integer
Dim sName as String
Dim iAge as Integer
hFile = FreeFile ' Get a free file handle
Open "c:\myfile.csv" For Input Access Read As hFile ' Open the file
Do While not EOF(hFile)
Input #hFile, sName, iAge
'-- Do something with sName and iAge...
Loop
Close #hFile ' Close the file once we reach the end
Yes, it involves more coding, but it does give you better control. And after all,
isn't that what programming is about? Writing some good solid code, not relying on
a good solid obscure feature that is not supported in future versions?
I hope this helps you out, Jeff. And remember, don't despair it's your
logic not your code that you need to keep from version to version.