473,836 Members | 1,358 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to requery a listbox on a form from another form

145 New Member
Hi again fellows,

I've got an annoying issue I can't seem to fathom. I have a Main or 'Home' form that has a tab control which houses a listbox, which is based on a query, and shows stocklevels.

From my invoicing form, once I've done my stock update calculations (I'm working on a more elegant solution), I need to requery the listbox on the main form to ensure the stock values shown are up to date.

I've tried 'everything'! Open and close the main form from the invoice form, requery the listbox from the invoice form, requery the listbox once the main form has the focus etc. Clicking my reset button on the main form updates the listbox just fine - I've tried cmdReset_Click from the invoice form (worked in Access 97!), but gives an error in 2007.

Sorry its so mundane, yet long to write out! Can someone help?

Many thanks.

Jan 30 '13
13 11133
2,322 Recognized Expert Moderator Top Contributor
You are welcome.

Note that Form_Frm_main is the reference to class object of your form.

When you open the form, then an object of that class gets added to the Forms collection, with a key Frm_Main. Thats why you can use the notations
Forms("Frm_Main ")

You can argue that the object in the forms collection is a Form_frm_Main but that within the collection it has been assigned the key frm_Main. (At least that is my basic understanding of the underlying mechanics).

Per default Access only opens 1 object of each form class, but it is possible to have the same form open multiple times, although it requires a slight bit more work.
Jan 31 '13 #11
32,584 Recognized Expert Moderator MVP
So to be completely disambiguous about my listbox:
Form_frm_Main.L ist55.Requery is about as explicit as I can get I think.
Good answer, but strangely, more helpful information would be where it is relative to the code that's running. If, as seems likely, the code is running from somewhere on the same form (within that same form's associated module) then referring to it using an external reference is not to be recommended at all. That simply adds to your maintenance overhead, and is easily avoided using the Me reference.

Thus, in that scenario (Most definitely doesn't work from outside of the scope of that same form.) the code would be :
Expand|Select|Wrap|Line Numbers
  1. Call Me.List55.Requery
NB. The external reference will still work of course. It is simply an overly clumsy way to code it in those circumstances.
Jan 31 '13 #12
145 New Member
NeoPa; You've just taught me something new. I didn't know you can call a method like that. Be assured I'll be using that!

Many thanks again,

Feb 5 '13 #13
32,584 Recognized Expert Moderator MVP
Very pleased to hear it :-)

I find most of my event procedures start with With Me and end with End With. If you don't know about With then that's another you would probably benefit from picking up.
Feb 5 '13 #14

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

Similar topics

by: fh1996 | last post by:
Form.Owner and Form.Parent, what's the difference between them? Form.ShowDialog() and Form.Show(), when to use which? Form.Activated(), what does it mean when saying a Form is "activated"? Thanks!
by: Riun | last post by:
My Main form acts as a Menu. It has 3 CmdButtons which directs to 3 Forms (Form 1, Form 2, Form 3). Form 1 also directs to the next, etc. My problem is that when I Click on the CmdButton that opens Form 1, Form 1 opens fine and ListBox displays info, BUT when I click on my CmdButton on Form1 that opens Main Form and then click on the CmdButton that opens Form1, Form 1 opens BUT says that the data in the listbox are deleted.
by: blyxx86 | last post by:
I can't seem to get this figured out. I am trying to requery another form after adding new information to a table that a cboList is created from. So, I have a combo box that has Sales personnel, and i have another form that lets me add sales personnel to the table of all the sales team. (Name, number, etc...) But when I open up the main form (with the combo box of Sales Personnel) and then open the form to add new members, or edit the...
by: bobdydd | last post by:
Hi All Access 2007 I have a form with a ListBox called "ListContactTasks" DoubleClicking the ListBox opens another form called "frmContact" at a particular record corresponding to the one in the listbox Column(0) The ListBox is on a form that has no recordset of it's own.
by: jebtrillion | last post by:
I want to fill a listbox that is on another form. I'm not sure how to declare it so the main form can see it. Help
by: Randy | last post by:
Hi, I've got a listbox on a form that gets updated by opening another form for data entry. Once the user enters the new item name and clicks "accept", the data entry form closes and the original form with the listbox displays. I'm having trouble getting the listbox to reflect the additional entry. If I close the form and reopen it, the new item displays just fine, but I know that there is a more direct way to force the listbox to...
by: kaosx5 | last post by:
I have a report sceniro where I have the user select a Report(acutally it is a macro but didn't want to confuse the user) off of Form1. When the user double clicks the Macro name it opens Form 2 which allows the user to put in critera. I want to be able to click a button on Form 2 that will run the Macro after the criteria has been entered. What would be recommended? Thank You.
by: lukasmazur | last post by:
Hi I have a problem with using listBox1. I have a two forms form1 and form2. In form1 are controls listBox1, textBox1 and button witch creating object of class Form2. In class Form2 I create a pointer to object of class Form1. I don't known how to use method add(), where can I find it. From Form1 I can add value like this this->listBox1- I cant find it. I have textBox1 on Form1 and I can change text in this control like this ...
by: ziycon | last post by:
I'm looking to add items on a listbox on form A from class B which is called from form A. I just don't know how to say add them to the listbox on the active form A from the class B!? It's in C#, can anyone help?
by: Organizer | last post by:
I am using Microsoft Access 2007. I have a list in a dropdown combobox (Field_One) in a form (Form_One). Users have the option to click a button if the item they need does not appear in the combobox, and another form, (Form_Two) opens to which they can add the new item (in Field_Two). After adding the new item in F_Two I want the combobox in F_One to requery without having to close and reopen F_One. I think I can do this with an After_Update...
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,...
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...
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...
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...
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...
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();...
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...
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: 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.