473,883 Members | 1,660 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 #1
13 11137
12,516 Recognized Expert Moderator MVP
Show us the code that you're using to refresh the list box. Also, what is the text of the error message?
Jan 30 '13 #2
145 New Member
I don't get any error messages, Rabbit. The latest thing I tried was DoCmd.Requery(. ..listbox55) in the Close event of the invoice form.

I'm guessing now that I'm going to have to fully close the invoice form before requerying the listbox. Essentially, I've tried the Requery command at just about every event!

It's feels such a silly, annoying issue (unlike my struggles with Allen Brownes 'onHand' code!), and there aren't many ways really to use requery.

Thanks for your time - especially at this time.


Jan 31 '13 #3
32,584 Recognized Expert Moderator MVP
It's perfectly possible to do by using :
Expand|Select|Wrap|Line Numbers
  1. Call {Reference to ListBox control}.Requery()
The only problem is determining the {Reference to ListBox control}. Referring to Items on a Sub-Form should help with that. If you struggle we can help, but only if you give us all the details you'll need for the reference.
Jan 31 '13 #4
12,516 Recognized Expert Moderator MVP
Post 1, paragraph 3 (not counting the greeting), last line. You say you get an error. Now you're saying you're not getting an error.

Also, this:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.Requery(...listbox55)
is not valid code so it should have thrown an error.

Per NeoPa's post, the most likely cause is an invalid reference to a control, which is why I wanted to see your requery code.
Jan 31 '13 #5
2,322 Recognized Expert Moderator Top Contributor
Whats the name of the form, name of the listbox control, and is the listbox in a subform?
Jan 31 '13 #6
145 New Member
Thanks for your replies.

I only got an error when I tried to 'remotely' click a button on my main form - cmdReset_Click.

The listbox is in a two page tab control, but not a subform. The main form is frm_Main, the listbox list55.

So to be completely disambiguous about my listbox:
Form_frm_Main.L ist55.Requery is about as explicit as I can get I think. The lisbox is on page one of a tab control: I dont have to reference that do I?


Jan 31 '13 #7
2,322 Recognized Expert Moderator Top Contributor
Ooops! Does tab send the post?
No but Tab (Which switches focus to the Post Reply Button) followed by a Enter or spacebar will submit :)

I don't use tab controls much, but no I don't think you need to include the tab control in the syntax.

Try this:
Expand|Select|Wrap|Line Numbers
  1. Forms!frm_Main.List55.Requery
P.s. Save yourself future headache and give the listbox a proper name!
Jan 31 '13 #8
Seth Schrock
2,965 Recognized Expert Specialist
I don't use tab controls much, but no I don't think you need to include the tab control in the syntax.
You are correct Smiley.
Jan 31 '13 #9
145 New Member
ha ha! Yes, and for anyone else listening, have a firm naming system. I have, but I slip sometimes when I'm fighting to get something done - and I pay for it every time!

Thanks guys,

Jan 31 '13 #10

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: 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,...
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: 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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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: 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.