473,800 Members | 2,406 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DoCmd.GoToRecor d fails when returning from OpenForm

martintallett
6 New Member
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.microso ft.com/kb/92685 )

ANY ideas gratefully received...

Martin
Oct 15 '07 #1
3 4895
MikeTheBike
639 Recognized Expert Contributor
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.microso ft.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
6 New Member
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
6 New Member
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.ht ml

Thanks for your help!
Oct 15 '07 #4

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

Similar topics

3
12586
by: Eric | last post by:
What's the best way to cancel the new record when doCmd.GoToRecord , , acNewRec is executed and before the new record is actually written to the database. I'm maintaining an existing Access 97 application. The main order form's recordsource is a query. On the form is an add button that uses doCmd.GoToRecord , , acNewRec to display an empty record and place the user in the first field. If the user tabs out of the first field (assuming...
1
17270
by: STeve Lefevre | last post by:
Hey folks -- I'm using the DoCmd.GoToRecord , , acNext to jump to the next record after the user enters a value. The problem is, it throws an error if it's already on the last record! What's the best way to prevent this? Steve Lefevre
0
1766
by: Timppa | last post by:
Hi, I'm converting ACCESS 2000 database to SQL Server. I have .adp project. In the .mdb I have form where I'll insert rows into two different tables using docmd.GoToRecod ,,acNewRec. In .adp form's Record source property I have following Stored Procedure (in .mdb there were similar query).
3
4521
by: Lyn | last post by:
Hi, I have a Search input form which collects from the user a person's name. I am using LIKE with a "%" suffix in the SQL so that the user does not have to type in the full name. When they hit the Search button, a query is run to search the Person table for a match. This produces a recordset (I am using ADO). If the RecordCount is zero, they get a No Match message. If the RecordCount is 1, a DoCmd.OpenForm is performed to open the...
15
3902
by: Thelma Lubkin | last post by:
formA determines some_where and some_value and issues docmd.close ,Me docmd.openform "formB", , ,some_where, , ,some_value formB receives the correct some_where and some_value After completing its work formB issues docmd.close ,Me docmd.openform "formA"
2
6870
by: Mike | last post by:
I am trying to open a search results form based on the input from a prompt form. I am using the following code: --- Begin Code --- Private Sub btnSearch_Click() 'Dim Variable and assign data Dim srce As String, fstnme As String, lstnme As String, bidnum As String srce = Me.Source_Control If Not IsNull(Me.Text18) Then
1
2601
by: vostrixos | last post by:
Hi all,i need some help I'm working on a access project were i use a lot the docmd.gotorecord ,,next ..first ..last method and i use only once the DoCmd.GoToRecord , , acNewRec.Everything was fine until i had to change the pop up property in a form.When that property is set to "yes" i get the error message: "you can't use the goto record action or method on an object in design view" I don't get that.wich object is on design vew.Is it the...
3
11810
by: gavm360 | last post by:
Hello, im trying to open a form from an dialog box form: the button on the dialog box has this on the onclick event: DoCmd.OpenForm "frmCASES_UNION", acViewNormal, , "MCH_CASECODE = #" & Me!txtCCODE & "#" the form I'm trying to open is "frmcases_union" and im trying to filter it by the "MCH_CASECODE" which i type into
1
2722
by: silen | last post by:
i am using Access2000. Currently i had a main form call "frmDownload" and sub form "fsubAdmmission". Under the fsubAdmmission, i do have another sub form "fsubHospital". Once i link my application to database A, when "frmDownload" loaded, it does successfully create "fsubAdmmission" object and i am able to assign "fsubAdmmission.form.recordsource". Once i link my application to database B, when "frmDownload" loaded, it failed to assign...
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.