Re: Update a Table Field from Form

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Tim Ferguson (FergusonTG_at_softhome.net)
Date: 12/16/04


Date: Thu, 16 Dec 2004 01:39:49 -0800


"=?Utf-8?B?SXJzaGFkIEFsYW0=?=" <IrshadAlam@discussions.microsoft.com>
wrote in news:55D328B1-B4AA-4022-87BA-7E98EEA372C4@microsoft.com:

> Sorry Sir, I was unable to make it by your advised code. I dont know
> why its shows error.

What error, in which line?

> I want to update all records of my Table ("ModiOT") from the Form
> ("UPSForm") on Command Button ("Click13") Click Event : For fast
> reference I will try in a look of coding :
 
 UPDATE ModiOT
 SET Status2= Forms!UPSForm!TextUps
 WHERE OtDate=Forms!UPSForm!DateUps

first of all, SQL does not recognise the Tables!ModiOT syntax, and
furthermore knows nothing about forms or controls. You have to build the
command literally in bits:

  strSQL = "UPDATE ModiOT" & vbnewLine & _
    "SET Status2 = """ & forms!upsform!textups & """" & vbnewline & _
    "WHERE OtDate = " & format(forms!upsform!dateups, c_strFormat)

  msgbox strSQL

and the msgbox will reveal something like this:

  UPDATE ModiOT
  SET Status2 = "Eric"
  WHERE OtDate = #2004/12/31#

which is what you (and Jet) need to see. If you get something else, post
back here.

Hope that helps

Tim F


Quantcast