Hi rpeare,
Thanks a lot for your quick reply, I have incorporated the code provided by you in the background of the Command17 button and I am facing the following error now.
Error Msg: Run-time error '3464': Data type mismatch in criteria expression
Actually post incorporating the code provided by you in command17 click event I had observed following things that when I updated the commentary in text15 box and clicked on the button it was showing some warning messages so to ignore those warning msgs I had set the warnings to off and start of click event and then set it On again at last but still I was facing an error like Syntax error (missing operator) in query expression '(((ID)=FI Cash))', I tried to investigate the error and had identified that when I select those products which had spaces in their names I was getting such error but if I select a product which didn't have space in between it's name it was working. for e.g. I have product like "DCM" and "FI Cash" in combobox dropdown If I select DCM it works fine but if I select "FI Cash" it throws above mentioned syntax error. To get rid of this syntax error I added Apostrophe / Single Quote in this line .i.e. '" & Me.Combo2 & "'))" so post that if I select it starting showing the data type mismatch in criteria expression.
Apart from the above error I need help on one more thing .i.e. in my database table .i.e. commentary table I have column called "Expected Data As of Date" now this column has those dates which the data provider is supposed to select in "Data As of Date" .i.e. DTPicker while submitting the commentary I want to put some code in the click event of the command17 which will look for the "Expected Data As of Date" for the product selected in the combobox and then try to match it with the date which selected by the user in the DTpicker and if it doesn't match then it will show a msgbox that the date selected by user is incorrect and he need to select the correct date. I tried to do the same by using dlookup .i.e. If Me.Dtpicker1.value <> dlookup("[Expected data as of date]"..... then show msgbox at the end of the clickevent code but unfortunately it didn't work. Can you please help me with the same as well.
Code:
Private Sub Command17_Click()
DoCmd.SetWarnings WarningsOff
Dim sSQL As String
sSQL = "UPDATE [Commentary Table] SET "
sSQL = sSQL & "[Commentary] = '" & Me.Text15 & "',"
sSQL = sSQL & "[Data As Of Date] = #" & Me.DTPicker1 & "# "
sSQL = sSQL & "WHERE (((ID)= '" & Me.Combo2 & "'))"
DoCmd.RunSQL sSQL
DoCmd.SetWarnings WarningsOn
'If Me.DTPicker1.Value <> DLookup("[Expected Data As of Date]", "[Commentary Table]", "[Product] = '" & Me.Combo2 & "'") Then
'MsgBox "The Commentary Date selected doesn't meet the expected Timeline. Please Select the Correct date"
'Else
'MsgBox "Commentary Submitted Successfully"
'End If
End Sub
Thanks a lot for your help in advance