473,757 Members | 10,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Refresh ComboBox After Adding New Values via a Separate Form

31 New Member
Hi,

I've been having a similar issue to what is described in the "refresh a form" post with a ComboBox that is not being refreshed after adding a new value on a seperate form. The second form is being opened via the standard DoCmd call.

I've tried adding Requery in AfterUpdate, Form_Current, etc. to no avail.... The test form has the combobox and a command button.

Here's my test code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddCatgCd_Click()
  2. On Error GoTo Err_cmdAddCatgCd_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "subfrmHierCatgCd"
  8.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  9.  
  10. Exit_cmdAddCatgCd_Click:
  11.     Exit Sub
  12.  
  13. Err_cmdAddCatgCd_Click:
  14.     MsgBox Err.Description
  15.     Resume Exit_cmdAddCatgCd_Click
  16. End Sub
  17.  
  18. Private Sub Form_AfterUpdate()
  19.     Me.Combo21.Requery
  20. End Sub
  21.  
  22. Private Sub Form_Current()
  23.     Me.Combo21.Requery
  24. End Sub
cmdAddCatgCd_Cl ick opens another form to maintain the code values that are populated in Combo21.

So far, the only way I've been able to get this to work is by adding a "Refresh" command button with the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command25_Click()
  2. On Error GoTo Err_Command25_Click
  3.  
  4.     Me.Combo21.Requery
  5.  
  6. Exit_Command25_Click:
  7.     Exit Sub
  8.  
  9. Err_Command25_Click:
  10.     MsgBox Err.Description
  11.     Resume Exit_Command25_Click
  12.  
  13. End Sub
I'd prefer having the requery happen automatically for both forms and subforms.....

Thanks, Ed.
May 7 '07
34 20228
bitsnbytes64
31 New Member
Thanks for posting the links Neo.



You have to open Maintform before you can set the tag property, once the Maintform is open (from formA) then me.name would return FormA since it is in the code for formA.

Then in the MaintForm you can type out the whole thing (Forms!MaintFor m1.Tag) however me.tag should be fine.

Expand|Select|Wrap|Line Numbers
  1. 'For Both Form_Close, Form_LostFocus events
  2. Debug.Print IsLoaded(Me.Tag)
  3.  
Happy coding...
Thanks for the help Denburt & NeoPa ! I'll let you know how I make out !

Ed.
May 10 '07 #21
NeoPa
32,572 Recognized Expert Moderator MVP
Thanks for the help Denburt & NeoPa ! I'll let you know how I make out !

Ed.
Hey, I'm a father of two. I don't need to know how you make out - Been there, Done that :D
(Sorry for that poor joke in even poorer taste - I just couldn't resist it.)

Seriously, we'd be glad to hear your results Bits.
May 10 '07 #22
Denburt
1,356 Recognized Expert Top Contributor
Hey, I'm a father of two. I don't need to know how you make out - Been there, Done that :D
(Sorry for that poor joke in even poorer taste - I just couldn't resist it.)

Seriously, we'd be glad to hear your results Bits.
As a father of two I would have to agree.

I was curious though is it a bit of a byte or is it a byte of the bit? j/k More dry humor.
May 10 '07 #23
bitsnbytes64
31 New Member
As a father of two I would have to agree.

I was curious though is it a bit of a byte or is it a byte of the bit? j/k More dry humor.
Maybe even a "nibble" ? LOL

BTW - When I left MaintForm1 open and either Alt-Tab'd or directly clicked on the calling form (FormA), the MaintForm1's Lost_Focus event never fired. Additionally, FormA's GotFocus event never fired either. Any ideas ?

Thanks, Ed.
May 11 '07 #24
Denburt
1,356 Recognized Expert Top Contributor
There are a lot of MS Access features I don't use much, however I just tested it with activate deactivate and it seems to work alright. I have also had mixed results with using the Activate/Gotfocus events.
May 11 '07 #25
bitsnbytes64
31 New Member
There are a lot of MS Access features I don't use much, however I just tested it with activate deactivate and it seems to work alright. I have also had mixed results with using the Activate/Gotfocus events.
Hey Denburt,

In MaintForm1's close event, what should the code be in order to use the Tag vs. the actual form name ?

e.g. If FormIsLoaded(Me .Tag) Then Forms!Tag.Reque ry vs. If FormIsLoaded(Me .Tag) Then Forms!FormA.Req uery

If I can't use Tag, then I have to add a line of for every form that calls MaintForm1....

Thanks, Ed.
May 11 '07 #26
Denburt
1,356 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. Forms(Me.tag).Requery  
Although you seem to be using it a fair amount so I would use either a local or a global variable to hold the form name then call that variable.

Expand|Select|Wrap|Line Numbers
  1. strFrm = Me.tag
  2. Forms(strFrm).Requery
May 11 '07 #27
bitsnbytes64
31 New Member
Expand|Select|Wrap|Line Numbers
  1. Forms(Me.tag).Requery  
Although you seem to be using it a fair amount so I would use either a local or a global variable to hold the form name then call that variable.

Expand|Select|Wrap|Line Numbers
  1. strFrm = Me.tag
  2. Forms(strFrm).Requery
Howdy,

Should I use an array in case more than one form is open ? I'd hope that the user would only have one form open but if that turns out not to be the case, I'd like to allow for it ? Or should I not consider it at all ?

Thanks, Ed.

BTW, I'm also a father of two and everyday is a new experience !
May 11 '07 #28
Denburt
1,356 Recognized Expert Top Contributor
That sounds like an idea it just depends on how things are set up in your db. I usually make sure that when i open 1 form I hide or close the calling one then I don't need to worry about it that much. I find it easier to manage that way.
May 11 '07 #29
bitsnbytes64
31 New Member
That sounds like an idea it just depends on how things are set up in your db. I usually make sure that when i open 1 form I hide or close the calling one then I don't need to worry about it that much. I find it easier to manage that way.
I just found out this only works when FormA calls MaintForm1. If they are opened seperately (via a menu for example) then add / update MaintForm1's values (which is possible as this is a code / decode form that can be accessed stand-alone as well as via another form), the combobox on FormA does not get updated..... This is turning out to be more work than it's worth and I'm sure this is mainly due to inexperience, but to make it easier, I'm going to add a refresh button on the calling form.....
May 11 '07 #30

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

Similar topics

5
4664
by: Aaron Ackerman | last post by:
I have a bound combobox the appears on a cell within the column of my bound grid when the user clicks on a cell n(In my vb.net WinForm app). I am trying to allow the adding of an item to that bound combo by allowing the user to dynamically type in the new value directly in the combo box whcih in turn updates the lookup table and then when they have finished leaves that particular cell on the grid with the correct value. Seems...
1
1308
by: ECathell | last post by:
I am getting an unspecified error when adding a windows form to a project. New project, old project. Doesn't matter. Also happens for user control. All the message box says is Unspecified Error. -- --Eric Cathell, MCSA
3
6079
by: awebguynow | last post by:
in other words, Can I make client side mod's before I submit a form and Post ? I guess its just a matter of cycling through the form elements and setting value to null (or empty string) for those that did not Change ( using onChange ).
0
5527
by: reloader | last post by:
Hi all, I would like to ask you about combobox refershing. My code is: <title>none</title> <body> <table border="1" width="100%" cellspacing="0" cellpadding="2"> <% dim m_DB
1
2150
by: BASSPU03 | last post by:
I've set my combobox to operate according to this option: "Find a record on my form based on a value I selected from my combobox." When I select a value from the combobox, I can see that the record on the navigation bar changes accordingly. (Example: Select "2000" and record is 1 of 21; select 2001 and record is 2 of 21; and so forth.) Unfortunately, when I press "Tab" from that combobox on the main form to a field in the subform and...
2
3163
by: billa856 | last post by:
Hi, My project is in MS Access. In that I have one Form in which I have some Comboboxes. 1st one is Independent, 2nd one is dependent on first one, 3rd one is dependent on 1st and 2nd both. After I load the form when I select an item from 1st one it will generate list for 2nd one, then I select an item from 2nd one it will generate list for 3nd one. Uptil this, all r done well. But after these selection if I change the selection of 1st...
1
1449
by: Mel | last post by:
On the SERVER SIDE, I need to get some values from form Elements and save the values into a file. Is this possible using Javascipt ? any exmple is highly appreciated
1
6514
by: hollywood115 | last post by:
Hey guys. I have a quick question... its very simple but i cant find a way to do it.. I need to add items to a combobox in a windows form... i need to have a name, and a value to go with it so they're associated with one another. whats the easiest way i can do this? i thought of creating a new class to handle it, but im sure c# has a way of doing that already.... thanks for your help.
5
2130
by: AccessHunter | last post by:
Hi, I have a continous form that displays Name and Address of Suppliers. In the form there is a combo box for 'Active Address' and 10 other text boxes. All the fields coem from one table, "Primary Suppliers". The combobox is for 'Active Address' with values 'Yes' and 'No'.Control source of the form is, Select * from PrimarySuppliers where ="Yes". I want the form to display only the Suppliers who has 'Active address' = "Yes".If user selects...
0
9489
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
9298
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
9906
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9737
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
8737
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...
0
6562
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
5172
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2698
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.