473,672 Members | 2,819 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HELP - Using GoToControl in subforms

Hi

I have created a form which contains a subform.

To cut a long story short, I have created a macro that moves the focus to
the subform (GoToControl) and sets a value (SetValue) in the field on the
subform that recieves the focus.

The basic steps of the macro are:

GotoControl [subform]
GoToRecord - First
SetValue

This macro works perfectly when I run it from the Tools-Macro-Run Macro
menu. ie. The value I want setting, is set on the first record in the
subform.

But when I trigger the macro by entering a value in the main form
(AfterUpdate), the GoToRecord - First command moves the focus to the first
record in my main form.

Can anyone explain why the macro works perfectly from the tools menu but not
when I trigger it by the After Update event?

I have run the macro through in single steps and tried everything else I can
think of but I think I am defeated by this one (Which sounds so simple).

Can anyone help?

Thanx


Dec 8 '05 #1
4 7711
Setting the focus to a control on a subform is a two step process.

1) Set the focus to the subform control on the main form
2) Set the focus to the control on the subform

You should be able to set the value without setting the focus to the
control. The syntax to refer to a control on the subform is

Forms!NameOfMai nForm!NameOfSub formControl.For m!NameOfControl OnSubform

However, this will place the value in the current record on the subform, not
the first record.

I tried playing with a macro to move the focus to a control on the subform,
but didn't get it right. It is doable in VBA using the method mentioned
above. You can also skip going to the control and just tell the subform to
move to the first record and assign a value to the control.

Example:
Me.NameOfSubfor mControl.Form.R ecordset.MoveFi rst
Me.NameOfSubfor mControl.Form.N ameOfControlOnS ubform = <your value>

--
Wayne Morgan
MS Access MVP
"Elaine" <el**********@v irgin.net> wrote in message
news:qc******** *********@newsf e7-gui.ntli.net...
Hi

I have created a form which contains a subform.

To cut a long story short, I have created a macro that moves the focus to
the subform (GoToControl) and sets a value (SetValue) in the field on the
subform that recieves the focus.

The basic steps of the macro are:

GotoControl [subform]
GoToRecord - First
SetValue

This macro works perfectly when I run it from the Tools-Macro-Run Macro
menu. ie. The value I want setting, is set on the first record in the
subform.

But when I trigger the macro by entering a value in the main form
(AfterUpdate), the GoToRecord - First command moves the focus to the first
record in my main form.

Can anyone explain why the macro works perfectly from the tools menu but
not when I trigger it by the After Update event?

I have run the macro through in single steps and tried everything else I
can think of but I think I am defeated by this one (Which sounds so
simple).

Can anyone help?

Thanx

Dec 8 '05 #2
"Wayne Morgan" <co************ *************** @hotmail.com> wrote in
news:N_******** ***********@new ssvr11.news.pro digy.com:
Example:
Me.NameOfSubfor mControl.Form.R ecordset.MoveFi rst
Me.NameOfSubfor mControl.Form.N ameOfControlOnS ubform = <your value>


I'm confused by this. Is it not possible for navigation in the
Recordset to cause the same kinds of problems that we refer to as
the Bookmark bug, which involved the RecordsetClone, which previous
to A2K was the only recordset that was usable for navigation? That
is, shouldn't you check for Me!NameOfSubfor mControl.Form.D irty and
set it to False before moving the recordset pointer?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Dec 9 '05 #3
David,

Checking for a dirty record first and saving it if it is (i.e. setting Dirty
to False) is probably a good idea and definitely won't hurt anything. I
haven't personally run across the bug, although I've heard about it.

--
Wayne Morgan
MS Access MVP
"David W. Fenton" <dX********@bwa y.net.invalid> wrote in message
news:Xn******** *************** ***********@216 .196.97.142...
"Wayne Morgan" <co************ *************** @hotmail.com> wrote in
news:N_******** ***********@new ssvr11.news.pro digy.com:
Example:
Me.NameOfSubfor mControl.Form.R ecordset.MoveFi rst
Me.NameOfSubfor mControl.Form.N ameOfControlOnS ubform = <your value>


I'm confused by this. Is it not possible for navigation in the
Recordset to cause the same kinds of problems that we refer to as
the Bookmark bug, which involved the RecordsetClone, which previous
to A2K was the only recordset that was usable for navigation? That
is, shouldn't you check for Me!NameOfSubfor mControl.Form.D irty and
set it to False before moving the recordset pointer?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc

Dec 9 '05 #4
"Wayne Morgan" <co************ *************** @hotmail.com> wrote in
news:tV******** ***********@new ssvr11.news.pro digy.com:
Checking for a dirty record first and saving it if it is (i.e.
setting Dirty to False) is probably a good idea and definitely
won't hurt anything. I haven't personally run across the bug,
although I've heard about it.


I think that anytime you know that an action that you're taking is
going to depart a record, it's a good idea to explicitly save the
record. This forces all error checking routines to run, whereas it's
clear that in some circumstances (e.g., the bookmark navigation
situation, the form close bug), that just doesn't happen.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Dec 9 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7467
by: JJMM | last post by:
Hi, I have a form (form1) with a large number of subforms inside it (around 20 subforms), There is the possibility of filtering the data using a pop-up form that create/change a query (all the subforms are linked to that query), Once that I create/change the query (using the pop-up form), Is there any easy way to update all the 20 subforms inside form1?. Normally I use to change the recordsource in each subform to show the
2
2557
by: mark | last post by:
I've been working on an Access 2000 database for a couple of weeks now. I took a course in access about a year ago, a crash course, and I learned a ton, but I didn't touch Access for the year since then so I forgot everything I learned : ( So this little project I envisioned has turned out to be much harder than I thought. But I think I'm close with it, so I want to see it through. What I wanted to create is a database that will track my...
2
2136
by: Mike | last post by:
Hi I have been tasked with converting my pulp and paper mills weekly projected and actual contractor hrs excel spreadsheet into a an Access 97 database. So far my design has been to use a form with a button for each to day navigate the recordset of a single table using .findfirst and .nomatch and I am worried about performance as I'm basically creating a flat file.
3
3417
by: radioman | last post by:
Hi all, I would appreciate some help please. I just need pointing in the right direction as I am at a loss. Basically I have a form (frmAddMaster) which displays two subforms "Master Stock subform" and "Client Stock Template subform". Each subform contains the following fields "Product ID,Product Description and Size". What I am trying to do is to select rows from the "Master Stock subform" and copy them to "Client Stock Template...
8
1989
by: newbie | last post by:
hello How can I update more than one tables on the same form? The relationship is one to many from a master table to 3 other related tables. on the form, I have to setvalue for a few fields(colums) in the related tables based on the value I enter in the field from the master table. I kept getting "you have to save the record before you update..." kind of message. Do you have any idea how to handle this? I feel I have to set the master...
4
2339
by: MLH | last post by:
HelpBox is a textbox control on a form. When line #254 is processed, the focus is on HelpBox. However, when line #254 executes, the error saying 'can't move focus to ButtonG' is returned. I've tried putting a DoEvents statement after line #253. The same error was returned. 252 DoCmd GoToControl "HelpBox" 253 HelpBox.ControlSource = "=" & Chr$(34) & HeadsUp & Chr$(34) 254 DoCmd GoToControl "ButtonG"
1
303
by: El | last post by:
Please help!! I have a form and in it are several subforms. In order for users to move from the main form to the subforms there are tabs on the upper part of the form. I have one field that when data is entered on the main form, I would like that same data to move to the same field on the next subform. How do I do this?? Any suggestions would be greatly appreciated. Thanks!!
3
2751
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality (we're sales offices, and I'm doing things such as associate directories, commission calculations, order tracking, etc.). 2003 seems to have a few extra features, but I seem to continually run in to oddities that seem like they SHOULD work, but...
1
2199
by: dlreich | last post by:
While viewing a form, I use Find (Ctrl-F) to find a new record. In On Current for the form, I use GoToControl to adjust the display of one of the fields in the new record. Is there any way I can determine what field the Find was going to place the focus on? I would like to get that information before I do the GoToControl so that I can use another GoToControl at the end of the On Current event to return focus where it would have been without...
0
8504
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
8419
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,...
1
8643
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8697
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...
0
7475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6255
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
5720
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();...
1
2837
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
2
2093
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.