kevin.dorrian
New member
- Local time
- Today, 22:40
- Joined
- Nov 3, 2007
- Messages
- 4
Hi Everyone,
Hours of frustration have led me to this point...
I have various functions in VB which will parse strings into start middle and ends dependent on the string format. So 3 functions will return a_, b and _c if fed a_b_c. There is more than one string format so there are 3 more functions for 0b0 etc.
These functions can obviously be grouped depending on the string format so I keep each function name and its parameters as a string in a field in a table. A user can select a record from a form and each of the 3 functions will be displayed through 3 fields in this form.
I want to loop through a list of strings and perform an INSERT INTO a sql table using variables. The variables are the fields in the form and therefore names of functions and their parameters.
I can perform the SQL INSERT easily enough but I can figure out how to replace the variable and then resolve the function before executing the SQL statement.
Here is the code, this will INSERT ok but it will insert the string from the table instead of resolving the function first.
Please can someone help. Im sorry if I havnt included enough info/included too much, im new to bug reporting.
Thanks,
Kev
Hours of frustration have led me to this point...
I have various functions in VB which will parse strings into start middle and ends dependent on the string format. So 3 functions will return a_, b and _c if fed a_b_c. There is more than one string format so there are 3 more functions for 0b0 etc.
These functions can obviously be grouped depending on the string format so I keep each function name and its parameters as a string in a field in a table. A user can select a record from a form and each of the 3 functions will be displayed through 3 fields in this form.
I want to loop through a list of strings and perform an INSERT INTO a sql table using variables. The variables are the fields in the form and therefore names of functions and their parameters.
I can perform the SQL INSERT easily enough but I can figure out how to replace the variable and then resolve the function before executing the SQL statement.
Here is the code, this will INSERT ok but it will insert the string from the table instead of resolving the function first.
Code:
Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant
Dim strSQL As String
Dim strEqu1 As String
Dim strEqu2 As String
Dim strEqu3 As String
'Add the files to the folder.
'Strips extension
strFolder = TrailingSlash(strFolder)
strTemp = Dir(strFolder & strFileSpec)
Do While strTemp <> vbNullString
strEqu1 = [Forms]![frmCode]![FileName]
strEqu2 = [Forms]![frmCode]![BeforeFilename]
strEqu3 = [Forms]![frmCode]![AfterFilename]
gCount = gCount + 1
SysCmd acSysCmdSetStatus, gCount
strSQL = "INSERT INTO tblexample " _
& "(fileName, filePath, fileExt, beforeFileName, afterFileName, dateImported) " _
& "SELECT """ & strEqu1 & """ " _
& ", """ & strFolder & """ " _
& ", """ & FileExtFromFile(strTemp) & """ " _
& ", """ & strEqu2 & """ " _
& ", """ & strEqu3 & """ " _
& ", """ & Date & """"
MsgBox strSQL, vbOKOnly, "debug"
CurrentDb.Execute strSQL
colDirList.Add strFolder & strTemp
strTemp = Dir
Loop
Please can someone help. Im sorry if I havnt included enough info/included too much, im new to bug reporting.
Thanks,
Kev