467,144 Members | 1,435 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,144 developers. It's quick & easy.

DoCmd.GoToRecord fails when returning from OpenForm

martintallett
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
  • viewed: 4491
Share:
3 Replies
Expert 512MB
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
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
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.

Similar topics

15 posts views Thread by Thelma Lubkin | last post: by
2 posts views Thread by Mike | last post: by
3 posts views Thread by gavm360@yahoo.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.