Regarding the Date Format, I changed to dd-mm-yyyy, as the table has
Doug has picked up this point -- you simply don't have a choice about
presenting dates to the Jet engine.
strSQL = "UPDATE ModiOT" & vbNewLine & _
"SET Status2 = """ & Forms!FormUps!TextUps & """" & vbNewLine & _
"WHERE OtDt = " & Format(Forms!FormUps!DateUps, c_strFormat) & _
"AND Namee = Forms!FormUps!Text6"
'Note : Form Text6 is the Text field as Well as the Table Field Namee
is also a text field
MsgBox strSQL
If you look at the message box, you'll spot a number of errors:
you need a space before the "AND ";
I strongly suspect that Namee is spelt wrong;
you need to substitute the _value_ of Forms!FormUps!Text6 rather than
just referring to its name;
Try this:
strSQL = "UPDATE ModiOT" & vbNewLine & _
"SET Status2 = """ & Forms!FormUps!TextUps & """" & vbNewLine & _
"WHERE OtDt = " & Format(Forms!FormUps!DateUps, c_strFormat) & _
" AND Namee = """ & Forms!FormUps!Text6 & """;"
By the way, Text6 is a really lame name to give your fields or controls --
you will find your life much easier if you give them names that mean
something. For a different reason, it's a bad idea to use words like "Name"
for fields because the word is reserved by VB or SQL or both. The same
applies to Text, Date, Integer, Count and so on. They are legal, and you
can get away with it, but they can create really hard bugs if you slip up.
I was not able to do the BETWEEN....AND criteria also :
If you think it's safe to use BETWEEN AND with dates (and I explained above
that I don't agree), then the syntax is easy enough:
strSQL = "SELECT etc..... " & _
"WHERE OtDt BETWEEN " & _
Format(CDate(Forms!FormUps!DateUps), c_strFormat) " AND " & _
Format(CDate(Forms!FormUps!DateEnd), c_strFormat)
After sorting it will update as same as above which we have written.
No sorting going on here, as far as I can tell. You need an ORDER BY clause
for that.