Goto a record in a subform via a macro.

F

Frank Martin

I have a "frmMain" and this has an unrelated
"frmSub".

There are text fields in each which have the
same value.

When I exit a record in the "frmMain", I
want to go straight to that record in
"frmSub" which contains the same-text value.

This is proving most difficult.

Can anyone please help me?
Frank
 
S

Steve Schapel

Frank,

Try it like this...

Action: GoToControl
Control Name: [frmSub]

Action: GoToControl:
Control Name: [NameOfTextboxOnSubform]

Action: FindRecord
Find What: =[NameOfTextboxOnMainForm]
 
F

Frank Martin

Thank you.

I still cannot get it to work, even when I
simplify it to the basics. E.g:

Find the text string 002885 in the
subform....

Action: OpenForm
Arguments:
Form Name: QrySuppPayments subform
View: Form
Filter Name: -
Where Condition: -
DataMode: Edit
WindowMode: Hidden.

Action: FindRecord
Arguments:
FindWhat: 002885
March: Any Part of Field
MatchCase: No
Search: All
SearchAsFormatted: No
OnlyCurrentField: No
FindFirst: Yes

If I use the "GoToControl action I get an
error "There is no field named
Forms![FrmLedgerAccnts]![QrySuppPayments
subform].Form![ChequeNumber] in the current
record.

I have used many macros before but never with
all this trouble.

Please help, Frank








in message
Frank,

Try it like this...

Action: GoToControl
Control Name: [frmSub]

Action: GoToControl:
Control Name: [NameOfTextboxOnSubform]

Action: FindRecord
Find What: =[NameOfTextboxOnMainForm]

--
Steve Schapel, Microsoft Access MVP


Frank said:
I have a "frmMain" and this has an
unrelated "frmSub".

There are text fields in each which have
the same value.

When I exit a record in the "frmMain", I
want to go straight to that record in
"frmSub" which contains the same-text
value.

This is proving most difficult.

Can anyone please help me?
Frank
 
S

Steve Schapel

Frank,

As mentioned in my earlier reply, you will need to use two GoToControl
actions. One to set the focus to the subform control itself, and then
one to set the focus to the required control within the subform.
 
F

Frank Martin

I don't want the focus in the subform, I just
need the appropriate subform record selected
so that I can "SetValue" a marker into a
field there.

I can do this already, but I have been unable
to SetValue the marker into the field
corresponding to the cheque number in the
subform matching the one in the main form.
No matter what I do the marker is always
inserted inti the *first* record of the
subform.

This is all very frustrating.

Regards, Frank





in message
Frank,

As mentioned in my earlier reply, you will
need to use two GoToControl actions. One
to set the focus to the subform control
itself, and then one to set the focus to
the required control within the subform.

--
Steve Schapel, Microsoft Access MVP

Frank said:
Thank you.

I still cannot get it to work, even when I
simplify it to the basics. E.g:

Find the text string 002885 in the
subform....

Action: OpenForm
Arguments:
Form Name: QrySuppPayments subform
View: Form
Filter Name: -
Where Condition: -
DataMode: Edit
WindowMode: Hidden.

Action: FindRecord
Arguments:
FindWhat: 002885
March: Any Part of Field
MatchCase: No
Search: All
SearchAsFormatted: No
OnlyCurrentField: No
FindFirst: Yes

If I use the "GoToControl action I get an
error "There is no field named
Forms![FrmLedgerAccnts]![QrySuppPayments
subform].Form![ChequeNumber] in the
current record.

I have used many macros before but never
with all this trouble.
 
S

Steve Schapel

Frank,

It has been pointed out to me by one of my esteemed colleagues that you
are opening the form Hidden. I'm sorry, I had not noticed that. I
don't think it will work to use a GoToControl action on a hidden form.
You may need to open the form so you can see it, and then the other
stuff might make sense.
 
S

Steve Schapel

Frank,

As advised previously, here and elsewhere, you need to use a FindRecord
action in your macro in order to move to the required record in the
subform. The FindRecord action required the focus to be on the control
that the Find is baing applied to.

I'm sorry, I don't know what else to do here. You are advised to do X.
Then you do Y and say it doesn't work. Well, I already know Y won't
work. Try X you'll have better luck.
 

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