Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing record within subform from main form 1

Status
Not open for further replies.

dameeti

Programmer
Dec 20, 2004
24
US
I tried to get this figured out a few months ago but it never worked.

I am specifying the record set within the main form, and after the correct recordset is brought in for the subform, I want to then change the current record within the subform, not just stay at the first record found in the set within the subform.

I can successfully set the focus on a field within the subform (from the code in the main form) -- well, it says it's successful.

Code:
Me.subformname.Form![subformfield].SetFocus

BUT when I try to then perform a FindRecord (on the line immediately follwing while still in the main form's AfterUpdate code), it fails (and remains at the first record in the record set). VERY frustrating. :-(

Code:
DoCmd.FindRecord subformfield

with a 2162 error "A macro set to one of the current field's properties failed because of an error in a FindRecord action argument".

Any thoughts and/or suggestions to make this work?

Thanks for all help provided. :)
 
And this ?
Me.subformname.SetFocus
Me.subformname.Form![subformfield].SetFocus

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Well, that avoided the eror on the FindRecord, but it didn't move to the desired record within the subform.

Progress :) ... but not success. :-( Any other ideas?
 
How are ya dameeti . . . . .

dameeti said:
[blue]DoCmd.FindRecord [purple]subformfield[/purple][/blue]
[purple]subformfield[/purple] should be the data your looking for, not a fieldname. Is this so?

Calvin.gif
See Ya! . . . . . .
 
Yes, you're right. It's NOT the field name, it a variable that contains what I'm seeking, not where I'm seeking.

I know it's right 'cuz my debug messages confirm what I'm loking for.

Silly me... sorry for the confusion. So any ideas?
 
GOOD news. After reviewing the code, I had a typo... so the first suggested fix DID fix it. Now the code works. So I had to first set the focus on the FORM, and then set the focus on the FIELD. That was the fix. Thanks for both of you. Case solved! Yea!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top