Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RunSQL to update field in a specific row in a table

Status
Not open for further replies.

Nvijayk

Technical User
Jul 10, 2002
26
0
0
GB
Hi

I need to update a field ( TransactionDate)in a row selected by a criteria ( TNo = '4') in a table (tblM)as when there is an update of a control ( StartDate)in a form which populates another table (tblCompanyinfo).

I tried this.
On the AfterUpdate property of the StartDate control on the form frmCompanyinfo as an event procedure.

DoCmd.RunSQL (UPDATE tblM) & _
SET TransactionDate = [Forms]![frmCompanyinfo]![StartDate]& _
WHERE TNo = '4';

It gives a compile error. highlighting tblM

Could someone please tell me whether the procedure adopted is first of all correct and if so why it is not working. How to do it correctly?

Regards

nvk
 
Try this:
dim strSQL as string

strSQL = "(UPDATE tblM) SET TransactionDate = "
strSQL = strSQL & [Forms]![frmCompanyinfo]![StartDate]
strSQL = strSQL & " WHERE TNo = '4';"
DoCmd.RunSQL strSQL

'Note you may have to put #'s around your start date

Cheers

Bruce
 
Thanks a million Bruce!
Shall revert if any problem
Regards

Vijay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top