Goto a record in a subform via a macro.

  • Thread starter Thread starter Frank Martin
  • Start date Start date
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
 
Frank,

Try it like this...

Action: GoToControl
Control Name: [frmSub]

Action: GoToControl:
Control Name: [NameOfTextboxOnSubform]

Action: FindRecord
Find What: =[NameOfTextboxOnMainForm]
 
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
 
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.
 
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.
 
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.
 
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.
 
Back
Top