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!

UPDATE Orders SET Selected = -1 WHERE OrderID = OrderID;

Status
Not open for further replies.

markvan

Technical User
Sep 12, 2001
37
0
0
AU
Problem with my WHERE
How do I reference the current record here
WHERE OrderID = currentrecord.OrderID ?
I have a button that runs a macro in the detail section, so I need it to work only on the current record.

I know this is basic, sorry.

Mark Van Laarhoven
Dot Imaging Online Printers, Sydney, Australia.
 
I think you will find that (Me.) OrderID, even when referenced on a continuous subform, is the OrderID of the current record.
 
UPDATE Orders SET Selected = -1 WHERE OrderID = Me.OrderID;

This brings up a parameter request, why isn't it recognising the current record, is it because the Me. refers to the Macro rather than the Current Record?

Mark Van Laarhoven
Dot Imaging Online Printers, Sydney, Australia.
 
Run code in the form containing the
Code:
Dim strSQL as String
strSQL = "UPDATE Orders SET Selected = -1 " & _
   "WHERE OrderID = " & Me.OrderID
DoCmd.RunSQL strSQL
This code assumes OrderID is numeric.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
markvan
If you encounter a similar problem with other macros, you may find this useful:
Refer to Form and Subform properties and controls

I think you are right about Me, you would need to say:

[tt]Forms![Form Name]![Subform Control Name].Form!OrderID[/tt]

However, as DHookom has pointed out, code is often easier and more controllable that a macro.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top