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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

go to specific form after requery

Status
Not open for further replies.

jpwgh

Technical User
Dec 6, 2007
4
US
Is there a simple way to go to a specific form after a requery? After the requery, I am at the first form. I would like to be at the form I was at when I did the requery. I have seen some code for subforms, but I am unable to get it to work for me.

Any help would be much appreciated.
 
One way is to set focus after the requery. I've found that sometimes you need to set focue to the control that, based on the tab order, is in order just before where you want the focus set, since the focus will actually go to the next control in the tab order. For subforms (assuming you are working from the main form), just setting the focus should work fine.

Me.chldSubFormx.setfocus

Bob
 
Thanks for your response. Sorry I did not do a very good job writing my initial question. I was trying to keep it short but in doing so I did not provide enough information.

I am using a form for data entry for an underlying table. I only have a main form, no subforms. One example I saw was for a subform. I tried to apply it to the main form without success. Although my unique field is numeric, I have been testing it using an alpha field. Some comments on some of the code indicated it was for text fields.

The closest I have come to getting it to do what I need was with this code:

Dim hldId
hldID = Me.LastName
Me.Requery
Me.Recordset.FindFirst "LastName =" & hldID

I got run-time error 3070 - MS Jet Database does not recognize (name in the LastName field of the record I was working on) as valid field name.

Any suggestions? Thanks again for your time and input.
 
I got it to work. Thank you for your time.
 
I get the impression that you are talking about records not forms, if so why not just grab the record number before the requery then use DoCmd.GoToRecord acDataForm, "Form1", acGoTo, 3, this will take you to record 3.

"Children are smarter than any of us. Know how I know that? I don't know one child with a full time job and children."...Bill Hicks
 
Try putting brackets around LastName:

Me.Recordset.FindFirst "[LastName] =" & hldID

Bob
 
Thank you both for your responses. I actually ended up using a different field for my unique field and it is working great....finally.

Thanks again.
 
Code:
Me.Recordset.FindFirst "LastName=[!]'[/!]" & hldID[!] & "'"[/!]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top