Changing recordsource for a form

GordonR

Registered User.
Local time
Today, 19:57
Joined
Aug 19, 2003
Messages
29
I have a form whose recordsource is set to
SELECT * FROM [Order]
which I want to change to a single specific record using while testing) as a click event on another form using:
Dim SQL As String
SQL = "SELECT * FROM [Order] WHERE ID = 72"
Forms![Review Order].RecordSource = SQL
DoCmd.OpenForm "Review Order"

I have tried putting this code in the "Review Order" forms form_load and form_open events but the form refuses to display.

What am I doing wrong?

Thanks!
 
Got it at last!!

The click event looks like (where ExOrderId is a Public long)
ExOrderId = [ID]
DoCmd.OpenForm "Review Order"

and the On open event for the 'Review Order' form contains
Dim SQL As String
On Error GoTo Err_Cancel_Click

SQL = "SELECT * FROM [Order] WHERE ID = " & ExOrderId
Me.RecordSource = SQL

That got it although I feel sure I tried that before. I have got into the habit now of compacting and repairing whenever I feel a funny is occuring. Is that a common thing?
 

Users who are viewing this thread

Back
Top Bottom