473,586 Members | 2,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Combo Box Rowsource set at GotFocus

I have a combo box on a form. It uses the GotFocus event to poopulate
the rowsource with a value list that is created on the fly in VBA. Fine
and dandy, except, is a user opens another form and returns to the form
with the rowsource, the rowsource is not refreshed because the combo
box doesn't execute the GotFocus event because it has never lost the
focus.
If I put the code to generate the value list in the MouseDown event of
the combo box it repopulates the value list just fine each time a user
clicks the combo box, but then it doesn't determine the item selected
from the combo box.
Sort of frustrating but I'm sure there's a simple solution to this?
Thanks,
lq

Nov 13 '05 #1
6 4212
Try having the form's GotFocus event call the combobox's GotFocus event.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"lauren quantrell" <la************ *@hotmail.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
I have a combo box on a form. It uses the GotFocus event to poopulate
the rowsource with a value list that is created on the fly in VBA. Fine
and dandy, except, is a user opens another form and returns to the form
with the rowsource, the rowsource is not refreshed because the combo
box doesn't execute the GotFocus event because it has never lost the
focus.
If I put the code to generate the value list in the MouseDown event of
the combo box it repopulates the value list just fine each time a user
clicks the combo box, but then it doesn't determine the item selected
from the combo box.
Sort of frustrating but I'm sure there's a simple solution to this?
Thanks,
lq

Nov 13 '05 #2
No luck with that. The Form's GotFocus event doesn't trigger. BTW-What
I'm populating the combo box with is a list of all open Access forms.
Even though I click other controls to open other forms, when I click
back on the switchboard form that contains the offending switchbox, it
doesn't trigger the GotFocus event of the list box unless I click
another control on the form first.

Nov 13 '05 #3
On Sun, 7 Aug 2005 13:57:17 -0400, "Douglas J. Steele"
<NOSPAM_djsteel e@NOSPAM_canada .com> wrote:

Perhaps the form_activate event would help. Depends on what kind of
form it is.

You could always offer a "refresh" button.

-Tom.

Try having the form's GotFocus event call the combobox's GotFocus event.


Nov 13 '05 #4
Most of my forms are popup forms so this doesn't allow the GotFocus
event to trigger as it otherwise would.
So what I have done is written code in the OnMouseMove event:

Sub myComboBoxName_ OnMouseMove

Dim myString as String, myValue as string

For each i in ...
'code here to extract each value...
myString = myString & ";" & myValue
Next i

If myString <> Forms!myFormNam e.myComboBoxNam e.RowSource Then
Forms!myFormNam e.myComboBoxNam e.RowSource = myString
End If

End Sub

This works fine however as you can see, the code is looping as long as
the mouse is over the combobox control, though it will only set the
rowsource once, so the user doesn't notice.

I need to figure out a way so that it only loops once as well...

Thanks,
lq

Nov 13 '05 #5
lauren quantrell wrote:
I have a combo box on a form. It uses the GotFocus event to poopulate
the rowsource with a value list that is created on the fly in VBA. Fine
and dandy, except, is a user opens another form and returns to the form
with the rowsource, the rowsource is not refreshed because the combo
box doesn't execute the GotFocus event because it has never lost the
focus.


Then do what I do. Make the code that generates from the ongotfocus
event of the combobox a standalone code in a standard module. In the
pop up form where you're performing actions that may affect the sql of
the combobox in question, pop in that code.

In doing such things, I always have the code in standard modules in case
the afterupdate events of other controls elsewhere needs to fire the
rebuild of the combo box.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto
Nov 13 '05 #6
Tom van Stiphout wrote:
On Sun, 7 Aug 2005 13:57:17 -0400, "Douglas J. Steele"
<NOSPAM_djsteel e@NOSPAM_canada .com> wrote:

Perhaps the form_activate event would help. Depends on what kind of
form it is.

You could always offer a "refresh" button.


I generally go for a "(refresh)" option at the end of the list if space
is at a premium or if the combo box is on a command bar.
Nov 13 '05 #7

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

Similar topics

0
3516
by: Krisa | last post by:
Hello all, I just discovered something (stop me if you've heard this before....) that was causing me a significant performance hit when opening a form with subforms. To speed up loading the form, I set the rowsources of its, and its subforms', combo boxes in the "Enter" events of the combo boxes. That's the standard trick for not...
3
9357
by: B | last post by:
I know there are several ways to speed up combo boxes and form loading. Most of the solutions leave rowsource of the combo box blank and set the rowsource to a saved query or an SQL with a where clause after users typed in one or several letters/digits. My problem is as follows Most of the time I need to display form in continuous format,...
2
5438
by: Sean | last post by:
Greetings all, I am attempting to make a form that will filter through several tables that (I believe) have refretial integrity. I am pulling data from several tables into the form and i would like to eventually be able to filter down through the tables untill i can reach one unique record. I am creating a datbase to keep track of...
9
3390
by: Bob Alston | last post by:
In 2002, "GrayJay" posted the following code: I did this in a jazz record catalogue to find composers - On a form "frmComposers" Create a text box - txtFindComposer, and add the following sub Private Sub txtFindComposer_Change() Requery Me!.SetFocus
4
5566
by: jcazmail-groups | last post by:
I have a child form that has a combo box whose underlying query needs to be filtered by a value from a combo box on the parent form. I have succeeded in doing this by putting the following SQL in the rowsource of the combobox: SELECT tblForms.idForms, tblForms.FormNumber, tblForms.FormName, tblForms.idCustomers FROM tblForms ORDER BY...
3
2200
by: Antoine Janssen | last post by:
hi, I would like to create two combo boxes. In the first one you can select a user in the second one you can select a project. To simplify the selection i would like to shorten the project list by just presenting the projects the selected user is working on (using a where clause with the userid filled in). Does onyone know how to achieve...
0
2918
by: Jeremy Wallace | last post by:
Folks, Here's a write-up I did for our developer wiki. I don't know if the whole rest of the world has already figured out how to do this, but I hadn't ever seen it implemented, and had spent a lot of time trying to figure it out, over the years. It finally dawned on me a couple of weeks ago how to do this. A couple of notes: 1) This is...
8
8243
by: salad | last post by:
I was wondering how you handle active/inactive elements in a combo box. Let's say you have a combo box to select an employee. Joe Blow has been selected for many record however Joe has left the company and has been flagged inactive. If you have a filter on the rowsource like Where Active = True then Joe's name would not show up in the combo...
2
1475
by: cyberdwarf | last post by:
Hi! I have inherited a continuous form whose detail area contains two combo boxes. The rowsource of the 2nd combo depends on the selection made in the 1st, and is rebuilt in the GotFocus event of the 2nd combo. This all works OK, BUT..... When I click into the 2nd combo, the contents of the 2nd combo of all existing rows on screen disappear,...
0
7911
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...
0
8200
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. ...
1
7954
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...
0
8215
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...
0
6610
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...
1
5710
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...
0
5390
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...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
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

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.