Hi all. First post here. Super new to messing around with VBA but have gotten pretty far I think. Here's the problem. I have a variable that contains a perfectly acceptable MySQL statement (as in, I can copy it into mysql directly and it works) yet when I run it through CurrentDb.Execute VariableName I get "Too few parameters. Expected 1."
Which the makes
The only thing I can think of is that I'm not declaring the column names because as you can see by the code, it's rather dynamic. So... Any ideas?
Code:
NewTicketChanges = "INSERT INTO ticketchanges VALUES (NULL," _
& Me.TFID & ",DEFAULT," _
& IIf(Me.TFDetails = CleanArray(1), "NULL,", "'" & EscapeQuotes(Me.TFDetails) & "',") _
& IIf(Me.TFStatus = CleanArray(2), "NULL,", Me.TFStatus & ",") _
& IIf(Me.TFPriority = CleanArray(7), "NULL,", Me.TFPriority & ",") _
& IIf(Nz(Me.TFAssignedTo, "") = Nz(CleanArray(4), ""), "NULL,", Me.TFAssignedTo & ",") _
& IIf(Me.TFCategory = CleanArray(3), "NULL,", Me.TFCategory & ",") _
& IIf(Nz(Me.TFCompany, "") = Nz(CleanArray(5), ""), "NULL,", Me.TFCompany & ",") _
& IIf(Nz(Me.TFLot, "") = Nz(CleanArray(8), ""), "NULL,", Me.TFLot & ",") _
& IIf(Nz(Me.TFWorkOrder, "") = Nz(CleanArray(6), ""), "NULL,", Me.TFWorkOrder & ",") _
& IIf(Me.TFSource = CleanArray(9), "NULL,", Me.TFSource & ",") _
& [TempVars]![tmpUserID] & ");"
CurrentDb.Execute NewTicketChanges
Which the makes
Code:
INSERT INTO ticketchanges VALUES (NULL,46,DEFAULT,'few af ae a',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,2);
The only thing I can think of is that I'm not declaring the column names because as you can see by the code, it's rather dynamic. So... Any ideas?