I have some code that works but is cumbersome to use.
with z as a variant I made calls like this:
z = Decode("Abi", "polo")
z = Decode("Abi", "xc70")
z = Decode("Abi", "208")
It would pass the values and do its job.
I didnt want to hand write every call so now I have a table of clients and a table of vehicles "to do"
I wrote this to create the string based on vehicles that need doing:
Public Function MakeStrCall(Str1 As String, Str2 As String, intType As Integer, Optional Str3 As String) As String
Dim StrOut As String
Dim DecodeStrFront As String
Dim StrEnd As String
Dim CleanStrFront As String
Dim StrComma As String
StrComma = ","
StrEnd = ")"
If intType = 1 Then
CleanStrFront = "BtnPrepareData_Click("
StrOut = CleanStrFront & Str1 & StrComma & Str2 & StrComma & Str3 & StrEnd
DecodeStrFront = "Decode('"
StrOut = DecodeStrFront & Str1 & "'" & StrComma & "'" & Str2 & "'" & StrEnd
MakeStrCall = StrOut
Private Sub CmdDecode_Click()
Dim Db As DAO.Database
Set Db = CurrentDb()
Dim rstRangetoProcess As DAO.Recordset
Dim strSQL As String
Dim z As Variant
strSQL = "SELECT TblClients.ClientName, TblWishlist.RangeToProcess, TblWishlist.Marque" _
& " FROM TblClients, TblWishlist" _
& " GROUP BY TblClients.ClientName, TblWishlist.RangeToProcess, TblWishlist.Marque;"
Set rstRangetoProcess = Db.OpenRecordset(strSQL)
Dim StrFunctionString As String
countRecords = .RecordCount
'cycle through the recordset
Do Until rstRangetoProcess.EOF
StrFunctionString = MakeStrCall(.Fields("ClientName").Value, .Fields("RangeToProcess").Value, 2)
z = StrFunctionString
'z = Decode("Abi", "polo")
'z = Decode("Abi", "xc70")
'z = Decode("Abi", "208")
an example of its output: Decode('Abi','208')
if i now do
z = StrFunctionString it doesnt work anymore, so would like advice on how to achieve.