Type Mismatch But makes no sense - vba

I am having a very strange Type Mismatch error and (to me at least) doesn't appear to be obvious.
I'm hoping a second set of eyes could help.
I'm getting a type mismatch where it's trying to set my Like "*"
I set Dim to a String and this field is all short text.
I've tried to get this two work two different ways but for some reason the code really doesn't like when I try to use Like "*" as a criteria.
The strange thing is if I use this in aa access query it works just fine.
Any help or push in the right direction would be appreciated.
I've tried it this way (preferred)
Private Sub AppendFilter_Change()
Dim UserF As String
Dim DateF As String
UserF = Me.UserFilterCombo
DateF = Me.AppendFilter
If UserF = "" Then
UserF = "Like "*"" '<---Type Mismatch??
Else
End If
Me.TasksLst.RowSource = "SELECT tblTasks.ID, tblTasks.Owner, tblTasks.[Task Name], tblTasks.Priority, tblTasks.Company, tblTasks.Status, tblTasks.Notes, tblTasks.DueDate, tblTasks.StartDate, tblTasks.DateCompleted, tblTasks.DateCreated, tblTasks.[Need Help], tblTasks.Assigned " _
& "FROM tblTasks " _
& "WHERE (((tblTasks.Owner)='" & UserF & "') AND " & DateF & " AND ((tblTasks.[Recurring Event])=False)) OR (((tblTasks.Owner)='" & UserF & "') AND ((tblTasks.Status)='Not Started') AND " & DateF & " AND ((tblTasks.[Recurring Event])=False)) OR (((tblTasks.Owner)='" & UserF & "') AND ((tblTasks.Status)='In Progress') AND " & DateF & " AND ((tblTasks.[Recurring Event])=False)) " _
& "ORDER BY tblTasks.Owner, tblTasks.DueDate;"
Me.TasksLst.Requery
End Sub
And I've tried it this way (Not my favorite)
Private Sub AppendFilter_Change()
Dim UserF As String
Dim DateF As String
UserF = Me.UserFilterCombo.Value
DateF = Me.AppendFilter
If UserF = "" Then
Me.TasksLst.RowSource = "SELECT tblTasks.ID, tblTasks.Owner, tblTasks.[Task Name], tblTasks.Priority, tblTasks.Company, tblTasks.Status, tblTasks.Notes, tblTasks.DueDate, tblTasks.StartDate, tblTasks.DateCompleted, tblTasks.DateCreated, tblTasks.[Need Help], tblTasks.Assigned " _
& "FROM tblTasks " _
& "WHERE (((tblTasks.Owner) Like " * ") AND " & DateF & " AND ((tblTasks.[Recurring Event])=False)) OR (((tblTasks.Owner) Like " * ") AND ((tblTasks.Status)='Not Started') AND " & DateF & " AND ((tblTasks.[Recurring Event])=False)) OR (((tblTasks.Owner) Like " * ") AND ((tblTasks.Status)='In Progress') AND " & DateF & " AND ((tblTasks.[Recurring Event])=False)) " _
& "ORDER BY tblTasks.Owner, tblTasks.DueDate;"
Else
Me.TasksLst.RowSource = "SELECT tblTasks.ID, tblTasks.Owner, tblTasks.[Task Name], tblTasks.Priority, tblTasks.Company, tblTasks.Status, tblTasks.Notes, tblTasks.DueDate, tblTasks.StartDate, tblTasks.DateCompleted, tblTasks.DateCreated, tblTasks.[Need Help], tblTasks.Assigned " _
& "FROM tblTasks " _
& "WHERE (((tblTasks.Owner)='" & UserF & "') AND " & DateF & " AND ((tblTasks.[Recurring Event])=False)) OR (((tblTasks.Owner)='" & UserF & "') AND ((tblTasks.Status)='Not Started') AND " & DateF & " AND ((tblTasks.[Recurring Event])=False)) OR (((tblTasks.Owner)='" & UserF & "') AND ((tblTasks.Status)='In Progress') AND " & DateF & " AND ((tblTasks.[Recurring Event])=False)) " _
& "ORDER BY tblTasks.Owner, tblTasks.DueDate;"
End If
Me.TasksLst.Requery
End Sub

I would have your logic so that the Where clause doesn't mention the user at all if the user hasn't specified a user (and same for date range - unless you want to put a default date range).
something like the below ... I haven't passed SQL statements to the rowsource, so I don't know how it uses the LIKE statement ... in SQL it would be single quote and % sign .... based on you using the *, this code uses single quote and star.
Private Sub AppendFilter_Change()
Dim UserF As String
Dim DateF As String
UserF = Me.UserFilterCombo
DateF = Me.AppendFilter
If UserF = "" Then
UserF = ""
Else
UserF = " AND (tblTasks.Owner) LIKE '*" & UserF & "*'"
End If
'repeat for DateF
Me.TasksLst.RowSource = "SELECT tblTasks.ID, tblTasks.Owner, tblTasks.[Task Name], tblTasks.Priority, tblTasks.Company, tblTasks.Status, tblTasks.Notes, tblTasks.DueDate, tblTasks.StartDate, tblTasks.DateCompleted, tblTasks.DateCreated, tblTasks.[Need Help], tblTasks.Assigned " _
& "FROM tblTasks " _
& "WHERE (( ((tblTasks.[Recurring Event])=False)) OR (((tblTasks.Owner)='" & UserF & "') AND ((tblTasks.Status)='Not Started') AND " & DateF & " AND ((tblTasks.[Recurring Event])=False)) OR (((tblTasks.Owner)='" & UserF & "') AND ((tblTasks.Status)='In Progress') AND " & DateF & " AND ((tblTasks.[Recurring Event])=False)) " _
& UserF & DateF _
& " ORDER BY tblTasks.Owner, tblTasks.DueDate;"
Me.TasksLst.Requery
End Sub

Related

Looping Code is not moving through the form

I have a form in my database that pulls data from a query to calculate the subassembly parts needed on a weekly basis and with the click of the "complete" button the required components should be moved into and out of inventory yet nothing happens when the complete button is clicked. The code should loop through and move all the parts but nothing happens.
I have stepped through to see if there are any errors and corrected a few syntax errors but that is all I have done.
Private Sub Command96_Click()
Dim ctl As Control
Dim ctln
Dim Qty As Double
Dim db As DAO.Database
Set db = CurrentDb
Dim rs As DAO.Recordset
For Each ctl In Me.Controls
Select Case TypeName(ctl)
Case "TextBox"
Select Case ctl.ControlName
Case ctl Like "*Q"
ctln = Me.Controls(Right(ctl, Len(ctl) - 1))
If Not IsNull(DLookup("[In]", "[Inventory]", "[PartNum] = '" & ctln & "'AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & "")) Then
num = DLookup("[In]", "[Inventory]", "[PartNum] = '" & ctln & "' AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & "") + ctl
Else
num = ctl
End If
If Not IsNull(DLookup("[PartNum]", "[Inventory]", "[PartNum] = '" & ctln & "'AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & "")) Then
CurrentDb.Execute "UPDATE [Inventory] " _
& "SET [In] = " & num & " " _
& "WHERE [PartNum] = '" & ctln & "'AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & "", dbFailOnError
Else
CurrentDb.Execute "INSERT INTO [Inventory] " _
& "VALUES ('" & ctln & "'," & Me.YearNum & "," & Me.WeekNum & "," & num & ",0)", dbFailOnError
End If
num = 0
Set rs = db.OpenRecordset("SELECT UsedPartNum, (Quantity * " & ctl & ") AS Used FROM SubPartsUsed WHERE FinPartNum = '" & PartNum & "'", dbOpenDynaset)
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do Until rs.EOF = True
If Not IsNull(DLookup("[Out]", "[Inventory]", "[PartNum] = '" & rs!UsedPartNum & "'AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & "")) Then
num = DLookup("[Out]", "[Inventory]", "[PartNum] = '" & rs!UsedPartNum & "' AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & "") + rs!Used
Else
num = rs!Used
End If
If Not IsNull(DLookup("[PartNum]", "[Inventory]", "[PartNum] = '" & rs!UsedPartNum & "'AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & "")) Then
CurrentDb.Execute "UPDATE [Inventory] " _
& "SET [Out] = " & num & " " _
& "WHERE [PartNum] = '" & rs!UsedPartNum & "'AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & ""
Else
CurrentDb.Execute "INSERT INTO [Inventory] " _
& "VALUES ('" & rs!UsedPartNum & "'," & Me.YearNum & "," & Me.WeekNum & ",0," & num & ")"
End If
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
End Select
End Select
I expect the parts to be entered into inventory as complete subassembly parts and the components to make them should be removed from inventory.
Code is done by high professional specialist in VBA, many shortcuts for code executing. It could be difficult for new VBA programmer to correct this code, so I think:
first step should be adding Debug.Print code executed here at line number XXX in order to study what lines are executed, and if their execution is done as assumpted.
After that, if there is OK with code logic, Debug.Print all SQL statements, that are generated. So you can check their correctness through executing in query designer
E.g.:
Private Sub Command96_Click()
Dim ctl As Control
Dim ctln
Dim Qty As Double
Dim db As DAO.Database
Set db = CurrentDb
Dim rs As DAO.Recordset
Dim sSQL As String
For Each ctl In Me.Controls
Select Case TypeName(ctl)
Debug.Pring "looping through controls"
Case "TextBox"
Select Case ctl.ControlName
Case ctl Like "*Q"
Debug.Pring "Control with Q letter is found"
ctln = Me.Controls(Right(ctl, Len(ctl) - 1))
If Not IsNull(DLookup("[In]", "[Inventory]", "[PartNum] = '" & ctln & "'AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & "")) Then
Debug.Print "Num is DLookuped"
num = DLookup("[In]", "[Inventory]", "[PartNum] = '" & ctln & "' AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & "") + ctl
Else
num = ctl
End If
If Not IsNull(DLookup("[PartNum]", "[Inventory]", "[PartNum] = '" & ctln & "'AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & "")) Then
Debug.Print "Executing Update Query for not null dlookup"
sSQL = "UPDATE [Inventory] " _
& "SET [In] = " & num & " " _
& "WHERE [PartNum] = '" & ctln & "'AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & ""
Debug.Print sSQL
CurrentDb.Execute sSQL, dbFailOnError
Else
Debug.Print "Executing Update Query for null dlookup"
sSQL = "INSERT INTO [Inventory] " _
& "VALUES ('" & ctln & "'," & Me.YearNum & "," & Me.WeekNum & "," & num & ",0)"
Debug.Print sSQL
CurrentDb.Execute sSQL, dbFailOnError
End If
num = 0
Set rs = db.OpenRecordset("SELECT UsedPartNum, (Quantity * " & ctl & ") AS Used FROM SubPartsUsed WHERE FinPartNum = '" & PartNum & "'", dbOpenDynaset)
If Not (rs.EOF And rs.BOF) Then
Debug.Print "Beginning action for each record in PartNum select query"
rs.MoveFirst
Do Until rs.EOF = True
If Not IsNull(DLookup("[Out]", "[Inventory]", "[PartNum] = '" & rs!UsedPartNum & "'AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & "")) Then
Debug.Print "Executing Dlookup for element in PartNum select query"
num = DLookup("[Out]", "[Inventory]", "[PartNum] = '" & rs!UsedPartNum & "' AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & "") + rs!Used
Else
num = rs!Used
End If
If Not IsNull(DLookup("[PartNum]", "[Inventory]", "[PartNum] = '" & rs!UsedPartNum & "'AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & "")) Then
Debug.Print "Executing Update for not null DLookup element in PartNum select query"
sSQL = "UPDATE [Inventory] " _
& "SET [Out] = " & num & " " _
& "WHERE [PartNum] = '" & rs!UsedPartNum & "'AND [YearNum] = " & Me.YearNum & " AND [WeekNum] = " & Me.WeekNum & ""
Debug.Print sSQL
CurrentDb.Execute sSQL
Else
Debug.Print "Executing Update for null DLookup element in PartNum select query"
sSQL = "INSERT INTO [Inventory] " _
& "VALUES ('" & rs!UsedPartNum & "'," & Me.YearNum & "," & Me.WeekNum & ",0," & num & ")"
Debug.Print sSQL
CurrentDb.Execute sSQL
End If
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
End Select
End Select
In this case you should study your Immediate windows (openes by Ctrl + G) to see, what is the execution plan, and what SQL texts are generated, and check all of them.
Otherwise, there is too many your business specific logics in this code, and it is quite impossible to understand program behavior. Maybe such behavior is assumpted, due to business logics? Many, many questions
Hit the F9 key over, and over, and over, until you see what the problem is. Also, leverage 'Add Watch' to see what values are passed to which variables. That should help immensely. Finally, if this is done by a professional, why are you using: 'Command96_Click()'? Of course that's not the problem, but it's not helping either.

Using NZ in a function in VBA to build query

I am really struggling here. I am building up a query inside VBA to link to several tables inside Oracle and inside Access. I need to make sure what I have uploaded to Oracle Matches what is in the Access DB.
I have:
SourceField1 (Always populated)
SourceField2 (Sometimes populated)
If source field 2 is blank I want to ignore it and not join to it. The best way I have done this is try with an Nz and replace with SourceField1.
strSQL = "INSERT INTO ERROR_TABLE (ORACLE_FIELD, TRANSFORM_FIELD) SELECT " & MatchValues!ORACLE_TABLE_NAME & "." & MatchValues!FieldName & ", " & MatchValues!TRANSFORM_TABLE_NAME & "." & MatchValues!FieldName
strSQL = strSQL & " FROM " & MatchValues!TRANSFORM_TABLE_NAME & " INNER JOIN " & MatchValues!xfTableName
strSQL = strSQL & " ON " & MatchValues!TRANSFORM_TABLE_NAME & "." & MatchValues!SourceField1 & " = " & MatchValues!xfTableName & "." & MatchValues!ReferenceField1 & ""
strSQL = strSQL & " AND " & MatchValues!TRANSFORM_TABLE_NAME & ".Nz(" & MatchValues!SourceField2 & "," & MatchValues!SourceField1 & ") = " & MatchValues!xfTableName & ".Nz(" & MatchValues!ReferenceField2 & "," & MatchValues!ReferenceField1 & ")"
strSQL = strSQL & " INNER JOIN " & MatchValues!ORACLE_TABLE_NAME & " ON (" & MatchValues!xfTableName
strSQL = strSQL & ".KEYVAL = " & MatchValues!ORACLE_TABLE_NAME & ".KEYVAL)"
strSQL = strSQL & " WHERE (" & MatchValues!TRANSFORM_TABLE_NAME & "." & MatchValues!FieldName
strSQL = strSQL & " <> " & MatchValues!ORACLE_TABLE_NAME & "." & MatchValues!FieldName & ")"
Which gives me this:
INSERT INTO ERROR_TABLE (ORACLE_FIELD, TRANSFORM_FIELD) SELECT UNI73MART1_DCappl.DECSN, tbluniDCappl.DECSN FROM tbluniDCappl INNER JOIN XF_DC_ref ON tbluniDCappl.REFVAL = XF_DC_ref.REFVAL AND tbluniDCappl.Nz(,REFVAL) = XF_DC_ref.Nz(,REFVAL) INNER JOIN UNI73MART1_DCappl ON (XF_DC_ref.KEYVAL = UNI73MART1_DCappl.KEYVAL) WHERE (tbluniDCappl.DECSN <> UNI73MART1_DCappl.DECSN)
Try this with proper concatenation of the Nz expressions:
strSQL = "INSERT INTO ERROR_TABLE (ORACLE_FIELD, TRANSFORM_FIELD) SELECT " & MatchValues!ORACLE_TABLE_NAME & "." & MatchValues!FieldName & ", " & MatchValues!TRANSFORM_TABLE_NAME & "." & MatchValues!FieldName
strSQL = strSQL & " FROM " & MatchValues!TRANSFORM_TABLE_NAME & " INNER JOIN " & MatchValues!xfTableName
strSQL = strSQL & " ON " & MatchValues!TRANSFORM_TABLE_NAME & "." & MatchValues!SourceField1 & " = " & MatchValues!xfTableName & "." & MatchValues!ReferenceField1 & ""
strSQL = strSQL & " AND " & MatchValues!TRANSFORM_TABLE_NAME & "." & Nz(MatchValues!SourceField2, MatchValues!SourceField1) & " = " & MatchValues!xfTableName & "." & Nz(MatchValues!ReferenceField2, MatchValues!ReferenceField1) & ")"
strSQL = strSQL & " INNER JOIN " & MatchValues!ORACLE_TABLE_NAME & " ON (" & MatchValues!xfTableName
strSQL = strSQL & ".KEYVAL = " & MatchValues!ORACLE_TABLE_NAME & ".KEYVAL)"
strSQL = strSQL & " WHERE (" & MatchValues!TRANSFORM_TABLE_NAME & "." & MatchValues!FieldName
strSQL = strSQL & " <> " & MatchValues!ORACLE_TABLE_NAME & "." & MatchValues!FieldName & ")"
Pull the call to Nz out of the SQL. The two fields in question exist in the VBA context and so should be checked within the VBA code, not embedded in the SQL string.
strSQL = strSQL & " AND " & MatchValues!TRANSFORM_TABLE_NAME & "." Nz( MatchValues!SourceField2 , MatchValues!SourceField1) & " = " & MatchValues!xfTableName & "." & Nz( MatchValues!ReferenceField2 , MatchValues!ReferenceField1)
When NULL is concatenated with a string using &, null is just converted to a blank string. So the expression ".Nz(" & MatchValues!SourceField2 & "," & MatchValues!SourceField1 & ") = " & MatchValues!xfTableName & ".Nz(" & MatchValues!ReferenceField2 & "," & MatchValues!ReferenceField1 & ")" would simply produce the string value ".Nz(, SourceField1Name) = tablename.Nz(,ReferenceField1Name)... which is bad SQL syntax. I think Nathan_Sav was trying to point this out, but not very clear about it.
Hint 1: You should always debug an SQL statement built in code by printing out the actual SQL statement. You should have included that in your question.
Hint 2: Try using the VBA line continuation character _

Can I convert my query to use select .. like .. or?

Can the query in the code below be converted to Select / Like / Or ?
Private Sub cmdQDef_Click()
Dim qd As DAO.QueryDef, db As DAO.Database
Dim ssql As String, WhereName As String, WhereTitle As String
Set db = CurrentDb
If Me.FilterName & "" = "" Then
DoCmd.OpenQuery "q_Search_qdef"
Exit Sub
Else
End If
ssql = "Select * From Employees"
Set qd = db.QueryDefs("q_Search_qdef")
WhereName = "'" & Replace(Me.FilterName, ",", "','") & "'"
WhereTitle = "'" & Replace(Me.FilterTitle, ",", "','") & "'"
ssql = ssql & " Where [First name] In(" & WhereName & ")AND " & _
"[Job Title] In (" & WhereTitle & ")"
qd.SQL = ssql
DoCmd.OpenQuery "q_Search_qdef"
End Sub
Yes:
WhereName = "'*" & Replace(Me.FilterName, ",", "','") & "*'"
WhereTitle = "'" & Replace(Me.FilterTitle, ",", "','") & "'"
ssql = ssql & " Where ([First name] Like " & WhereName & ") OR " & _
"([Job Title] In (" & WhereTitle & ")"

VBA SQL Join Query

I am having troubles with a VBA SQL JOIN. I Keep Getting A "Join Expression Not Supported" Error. The Following Code Works In The Query Design View but seems to throw an error when in vba.
Dim Rs As DAO.RecordSet
Set Rs = CurrentDb.OpenRecordset( _
"SELECT Schools.ID, Schools.[School Name],Schools.Address, Schools.Postcode, Schools.[Principal name], " & _
"Schools.[E-Mail], Schools.Phone, Schools.Region, Schools.JTHE, Schools.[Social Status], Events.Program " & _
"FROM Schools INNER JOIN Events ON Schools.ID = Events.School WHERE ((Schools.Region = '" & RegionOne & _
"' Or Schools.Region = '" & RegionTwo "' Or Schools.Region = '" & RegionThree "' Or Schools.Region = '" & _
RegionFour "') AND (Schools.JTHE = " & JTHE1 & " Or Schools.JTHE = " & JTHE2 ") AND (Schools.[Social Status] = '" & _
StatusBox.Value "') AND (Events.Program = '" & ProgramBox.Value & "'));")
This Similar Query Works
Set Rs = CurrentDb.OpenRecordset("SELECT * FROM Schools WHERE " & _
"(((Schools.Region)='" & RegionOne & _
"' Or (Schools.Region)='" & RegionTwo & _
"' Or (Schools.Region)='" & RegionThree & _
"' Or (Schools.Region)='" & RegionFour & _
"') AND ((Schools.[Social Status])='" & StatusBox.Value & _
"') AND ((Schools.JTHE)=" & JTHE1 & " Or (Schools.JTHE)=" & JTHE2 & "));")
Any help would be greatly appreciated.
I'm not entirely sure why is that. It is hard to spot error when your doing it on VBA, unlike if your in an actual SQL Management studio where you can spot the lines that errors out. Nonetheless, you may try this:
Set Rs = CurrentDb.OpenRecordset( _
"SELECT Schools.ID, Schools.[School Name], Schools.Address, " & _
"Schools.Postcode, Schools.[Principal name], Schools.[E-Mail], " & _
"Schools.Phone, Schools.Region, Schools.JTHE, Schools.[Social Status], " & _
"Events.Program " & _
"FROM Schools " & _
"INNER JOIN Events " & _
"ON Schools.ID = Events.School " & _
"WHERE Schools.Region IN (" & _
"'" & RegionOne & "'," & _
"'" & RegionTwo & "'," & _
"'" & RegionThree & "'," & _
"'" & RegionFour & "') " & _
"AND Schools.JTHE IN (" & JTHE1 & ", " & JTHE2 & ") " & _
"AND Schools.[Social Status]='" & StatusBox.Value & "' " & _
"AND Events.Program='" & ProgramBox.Value & "';")
I formatted it as such to give you the story of the query (and that is how I will write it in SQL). Not really a direct to the point answer to your question but I just simplified your OR statements and instead uses IN. You might get a:
Too many continuous line error
So adjust the concatenation of strings. I have not tested this of course (although it compiles) but my goal is to give you idea on a possible way to do it. HTH.

Using variables in fieldnames - SQL Update statement

I am new to using Access 2010. I wish to execute the following sql update statement, but I have problems with the syntax. The table is called "Forecasts", and users will edit & update the qty forecasted.
Problem - The table fieldnames are 2014_1, 2014_2, 2014_3 ... to represent the different months, stored in an array. I have done abit of research and I believe the way to dynamically do this is:
Dim sqlString As String
sqlString = "UPDATE Forecasts " & _
" SET Branch_Plant=" & Me.txtBranch_Plant & _
", Item_Number_Short='" & Me.txtItem_Number_Short & "'" & _
", Description='" & Me.txtDescription & "'" & _
", UOM='" & Me.txtUOM & "'" & _
", Estimated_Cost=" & Me.txtEstimated_Cost & _
", Requesting_Business_Unit='" & Me.txtRequesting_Business_Unit & "'" & _
", End_Customer='" & Me.txtEnd_Customer & "'" & _
", Project='" & Me.txtProject & "'" & _
", Forecasts." & "[" & arrMonthToDisplay(0) & "]" = " & Me.txtProjectedJanVolume " & _
" WHERE ID =" & Me.txtID.Tag
MsgBox ("This is the output: " & sqlString)
CurrentDb.Execute sqlString
It was working fine until this line was added
Forecasts." & "[" & arrMonthToDisplay(0) & "]" = " & Me.txtProjectedJanVolume
The msgbx output now shows: "False". Whats wrong with sqlString?
Please help! Thank you very much.
", Forecasts.[" & arrMonthToDisplay(0) & "] = " & Me.txtProjectedJanVolume & _
" WHERE ID =" & Me.txtID.Tag
You compare string to string.
Change
", Forecasts." & "[" & arrMonthToDisplay(0) & "]" = " & Me.txtProjectedJanVolume " &
to
", Forecasts." & "[" & arrMonthToDisplay(0) & "] = " & " Me.txtProjectedJanVolume " &