By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,503 Members | 2,788 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,503 IT Pros & Developers. It's quick & easy.

DoCmd.GoToRecord fails when returning from OpenForm

martintallett
P: 6
Help!

I am trying to replace the Access Find button functionality on an old database.

I can make it work when I use a basic form with bound fields and a button which shows a popup form which then finds the record the user wants then does a GoToRecord on the basic form.

However...

When I try to put this to work in the real world the form with the record context to GoToRecord is a subform and it only partially works.

That is to say if I add a button to the subform and use it to do the GoToRecord action it works...

But if I use the same button, call the popup form and THEN do the GoToRecord it fails...

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdFind_Click()
  2.  DoCmd.OpenForm "NewSearchForm"
  3.  DoCmd.GoToRecord , , acGoTo, 612
  4. End Sub
  5.  
This fails...

If I take the OpenForm command out it works...

I have tried various combinations of the GoToControl action and SetFocus method as well to try and set the context correctly but, nope, it does not work
(as recommended here http://support.microsoft.com/kb/92685 )

ANY ideas gratefully received...

Martin
Oct 15 '07 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 634
Help!

I am trying to replace the Access Find button functionality on an old database.

I can make it work when I use a basic form with bound fields and a button which shows a popup form which then finds the record the user wants then does a GoToRecord on the basic form.

However...

When I try to put this to work in the real world the form with the record context to GoToRecord is a subform and it only partially works.

That is to say if I add a button to the subform and use it to do the GoToRecord action it works...

But if I use the same button, call the popup form and THEN do the GoToRecord it fails...

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdFind_Click()
  2.  DoCmd.OpenForm "NewSearchForm"
  3.  DoCmd.GoToRecord , , acGoTo, 612
  4. End Sub
  5.  
This fails...

If I take the OpenForm command out it works...

I have tried various combinations of the GoToControl action and SetFocus method as well to try and set the context correctly but, nope, it does not work
(as recommended here http://support.microsoft.com/kb/92685 )

ANY ideas gratefully received...

Martin
Hi

The logic of what you are doing is unclear to me, particularly as you are going to record 612 regardless, but would opening the form as a dialog form hepl

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdFind_Click()
  2.  DoCmd.OpenForm "NewSearchForm", , , , , acDialog
  3.  DoCmd.GoToRecord , , acGoTo, 612
  4. End Sub
  5.  
This (should) has the effect of stopping the code until the NewSearchForm is closed.

Just a suggestion!?

MTB
Oct 15 '07 #2

martintallett
P: 6
Hi

The logic of what you are doing is unclear to me, particularly as you are going to record 612 regardless, but would opening the form as a dialog form hepl

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdFind_Click()
  2.  DoCmd.OpenForm "NewSearchForm", , , , , acDialog
  3.  DoCmd.GoToRecord , , acGoTo, 612
  4. End Sub
  5.  
This (should) has the effect of stopping the code until the NewSearchForm is closed.

Just a suggestion!?

MTB
Ahhh sorry ...

The theory is that the NewSearchForm comes up with a record number to go to and then makes the form that called it go to that record. I have not implemented that part yet. The 612 is just a tester to see if I can make it work! The form is set as a PopUp and Modal so there should be no problem there.
Oct 15 '07 #3

martintallett
P: 6
Problem solved!

Expand|Select|Wrap|Line Numbers
  1.    Set rs = Forms!Main.Sub.Form.RecordsetClone
  2.    rs.FindFirst ("JobNo=" & Trim(lstSearchResults.ItemData(i)))
  3.    Forms!Main.Sub.Form.Bookmark = rs.Bookmark
  4.  
does the same thing as a GoToRecord action... My main form is called Main and the subform control on the Main form is called Sub.

It was here
http://www.thescripts.com/forum/thread188328.html

Thanks for your help!
Oct 15 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.