Thread: OpenForm Macro
View Single Post
  #4  
Old May 23rd, 2010, 10:53 AM posted to microsoft.public.access
Wolfgang Kais[_4_]
external usenet poster
 
Posts: 18
Default OpenForm Macro

Hello Amy.

"dirtrhoads" (Amy) wrote:
I have set up an OpenForm macro on a double click event in a subform.
The subform is titled Active Orders at Belmont Subform. The form I
have set to open is Order Details. I have set up the macro to open
Order Details when I click on the PO_Number from my subform and it
opens perfect, however, I want it to open up to the record I double
clicked. As of right now, it is opening up to the first record.
I tried typing in PO_Number in the WHERE clause but this caused the
event to open up to a New Record...


Wolfgang answered:
The WHERE clause sould have the form "PO_Number = 123". Since the
number depends on a field of the current record, this WHERE clause has
to be calculated. Try something like this in the argument:
="PO_Number = " & [PO_Number]


"dirtrhoads" came back:
Wolfgang,

Thank you for your suggestion, but unfortunately that didn't work. When
I entered it exactly as you had it it gave me an error that says "You
may have specified a control that wasn't on the current object without
specifying the correct form or report context".


Try replacing the name in [PO_Number] by the correct name of the
corresponding control on the subform.

So I entered this into the WHERE clause:

="PO_Number = " & [Forms]![Order Details]![PO_Number]

but this gave me another error stating that form i referenced was
either closed or did not exist.


Here, you have referenced a control on the form that you were going to
open. You should have referenced the control on the subform that contains
the PO_Number that you want to use in the WHERE clause.

So, i opened the form, minimized it and then ran the macro again and it
asked me for a parameter and I'm assuming this is because my PO Numbers
are alpha numeric...?


I don't think so, but probably the record sorce for the Order Details form
does not contain a field named PO_Number. Verify the name of the field and
correct the first part of the WHERE clause argument:
="[correct field name] = " & ...
Since your field seems to be of type text, try the following:
="[correct field name] = '" & [correct control name] & "'"

I'd like to be able to double click the PO Number from subform without
having to have Order Details open/minimized, and also not to have to
enter the Alpha parameter... will this be possible?


Sure. Try my suggestions and the we'll see. If this dosn't work either,
try to replace [correct control name] by the complete path to the control:
[Forms]![name of main form]![name of subform control].Form![correct control
name]

--
Regards,
Wolfgang