Click a subform field to open relevant form


C

CDIT

Hi, this is my first post :blush:)

l've created a main menu form in Access 2007 called “frmSwitchboard”
and embedded in that is a subform called "subfrmSwitchboard" that
contains all customer orders of a certain type (Active, Paid, Unpaid).
Each order has an Autonumber field called ID as it's primary key.

Linked to the ID field on the subform is a macro that should open up
"frmOrders" with the relevant order number's record shown when you
click the relevant ID number on the subform. If I open up the subform
on its own in datasheet view and click an ID field then the relevant
order form appears, great.

However, if I do this within the subform being present on the main
form (frmSwitchboard) it doesn’t, I get an input box appearing with
the WHERE clause from my macro showing:

Forms!subfrmswitchboard!ID

The WHERE clause in the macro is: [ID]=[Forms]![subfrmswitchboard]!
[ID]

If I type in the order ID then the form appears but I want this
nuisance not to be the case. Where have I gone wrong?

Many thanks in advance.
 
Ad

Advertisements

L

Lord Kelvan

You need to reference the subform through the mainform because the
subform is not "open" as per say in the [forms] collection

Use the condition

[ID]=[Forms]![ frmSwitchboard]![subfrmswitchboard]![ID]

If you open this subform as a normal form as well then tell me and you
need to do something more complicated as this condition will not work
in that case.

Regards
Kelvan
 
T

Tom van Stiphout

On Thu, 27 May 2010 18:45:35 -0700 (PDT), Lord Kelvan

Actually that should be:
[ID]=[Forms]![ frmSwitchboard]![subfrmswitchboard].Form![ID]

The way I think about this syntax is that [Forms]![
frmSwitchboard]![subfrmswitchboard] accesses the subform control, so
you could inspect its properties (e.g. Left, SourceObject, etc).
..Form makes you step into the (sub)form and now you can access the
controls in that form.

-Tom.
Microsoft Access MVP
 
C

CDIT

On Thu, 27 May 2010 18:45:35 -0700 (PDT), Lord Kelvan


Actually that should be:
[ID]=[Forms]![ frmSwitchboard]![subfrmswitchboard].Form![ID]

The way I think about this syntax is that [Forms]![
frmSwitchboard]![subfrmswitchboard] accesses the subform control, so
you could inspect its properties (e.g. Left, SourceObject, etc).
.Form makes you step into the (sub)form and now you can access the
controls in that form.

-Tom.
Microsoft Access MVP


You need to reference the subform through the mainform because the
subform is not "open" as per say in the [forms] collection
Use the condition
[ID]=[Forms]![ frmSwitchboard]![subfrmswitchboard]![ID]
If you open this subform as a normal form as well then tell me and you
need to do something more complicated as this condition will not work
in that case.
Regards
Kelvan
Hi and thanks very much for the prompt responses.

Unfortunately I have tried both and the input box still appears :blush:(

Any other ideas and contributions will be greatly appreciated.

Many thanks again.
 
L

Lord Kelvan

Interesting my code works fine for me I don’t need to use .form![id]
though it doesn’t matter it did not work for him.

BWAHAHA

My fault I am so sorry and well-done to Tom van Stiphout FOR THE COPY
PASTE OF MY MISTAKE =P

[ID]=[Forms]![ frmSwitchboard]![subfrmswitchboard]![ID]

There is a space there you’ll see it if you look close

Try this

[ID]=[Forms]![frmSwitchboard]![subfrmswitchboard]![ID]

Regards
Kelvan
 
Ad

Advertisements

Joined
Aug 15, 2013
Messages
1
Reaction score
0
hello, this is my first post. I have a similar problem/issue. my subform however is a continuous list of records. i tested the open form concept using a button with embedded macro. while the macro works, it always selects the first record on the subform, even if i my "cursor" is on a different record. how do i open a mtc form to edit a specific record being selected from a continuous subform? THANKS in advance for any help.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top