Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Requery menu form
Daniel Schuster 
     
2 years ago
My menu forms don't have a Record Source, so they don't seem to be able to be Refreshed or Requeried. The work around I found was to have a timer close then re-open the form. Is there a better way?
Kevin Robertson  @Reply  
          
2 years ago
If the Form is unbound why does it need to be Requeried?
Are there controls on the form that need Requerying such as a Text Box or a List Box?
Daniel Schuster OP  @Reply  
     
2 years ago
I want the user to be aware of new orders, so I have a button that changes colors when there's a new order. But when the new order is dealt with, the menu doesn't update back to the default color without closing and reopening the menu.
Sami Shamma  @Reply  
             
2 years ago
How do you tell the user there are new orders?
When the user "deals" with the order, why not change the color in VBA code on Form Close or unload?
Daniel Schuster OP  @Reply  
     
2 years ago
By a button changing colors on the main menu.

When I have the 'orders' form close I tell the main menu to refresh/requery but because it doesn't have any Record Source it doesn't make any difference.
Richard Rost  @Reply  
          
2 years ago
If you have an unbound Main Menu form, for example, you can still issue a Me.Refresh on that form either in a button or in a timer event. You don't need to close and reopen it.
Kevin Yip  @Reply  
     
2 years ago
Hi Daniel, requery only affects data, not button's color.  Like Sami said, you need VBA to change the button's color based on whether new orders are present at any given moment.

Create a function to count the number of new orders.  E.g.:

    Public Function GetNewOrderCount() As Long
        ' Write code here to count new orders.
        GetNewOrderCount = ...
    End Function

Then change button's color based on new order count.  E.g.:

    Me.MyButton.BackColor = IIf(GetNewOrderCount > 0, vbRed, vbGreen)

Then put this line at key locations in your app, such as when an order is submitted, processed, cancelled, re-instated, etc.
Sami Shamma  @Reply  
             
2 years ago
I like the way Kevin explain things.

Thak you.
Daniel Schuster OP  @Reply  
     
2 years ago
Richard, is there anything that would block the Me.Refresh command? I have a button on that menu to refresh it and it has no effect.

Kevin. I have a VBA code to change the color based on if there are new orders or not. The button works correctly, but when I try to update the button with the fact that there are no new orders (or vice versa), the Me.Refresh has no effect and the only way I can refresh the menu to reflect the correct color button is to close the main menu form and reopen it.
Kevin Yip  @Reply  
     
2 years ago
Like Requery, Refresh only affects data, not button colors, nor any format settings used on anything on the form.  Requery, Refresh, and Repaint cannot "reset" the form to the settings you specified at design time.  Those settings are only known to Access when the form is in design view.  When the form is in form view, it cannot be in design view, therefore Access can't retrieve the design view settings.  And that's why Requery, Refresh, and Repaint don't work for that purpose.  Only your VBA code would work.  You need to use the same VBA method to change the button color when there is no new order.

While a form is running, it doesn't (and can't) keep a "history" of the possibly hundreds of changes to its button colors, form background colors, font styles, visibility settings, etc.  So only you can tell the form what to do, every step of the way, with your code.
Daniel Schuster OP  @Reply  
     
2 years ago
Ok, I'm giving that formula a try. I'm using the formula from <A HREF="https://599cd.com/blog/display-article.asp?ID=1526"><B>Here</B></A>  for the code that counts the orders but it's not working. Can this function use DLOOKUP from a Query?
Kevin Yip  @Reply  
     
2 years ago
If you want the number of orders to be part of the notification to your users, you need to use DCount() to get an actual count.  If you  only need to know whether or not a new order is present, DLookup() may suffice.  DLookup() only returns one record, and if it finds just one new order, that means new orders are present.
Daniel Schuster OP  @Reply  
     
2 years ago
From the VBA code area, I deleted the 'Private Sub' and then added the following:

Public Function ChangeButtonColor() As Long
      ChangeButtonColor = NZ(Lookup("OrderID", "NewOrderQ"), 0)
      Me.OrdersBtn.Backcolor = IIF(ChangeButtonColor = 0, vbRed, vbBlue)
End Function

That renders no change. Am I getting close?  I really appreciate your time.
Kevin Yip  @Reply  
     
2 years ago
You can't use "ChangeButtonColor" as a variable because it is the name of the function itself.  You need to declare a variable with a different name.  Also, it's DLookup instead of Lookup.  Finally, this function "ChangeButtonColor" needs to be called in order to do anything.  Where is this function called?  If a function isn't called anywhere, it does nothing, and that may be why you see no changes.
Alex Hedley  @Reply  
            
2 years ago
Daniel Schuster OP  @Reply  
     
2 years ago
Thank you Kevin and Alex. I see that I am missing a basic knowledge of Functions. I'll work on that. Thank you! For now, I'm having a pop-up message on a timer if there are any new orders.
Sami Shamma  @Reply  
             
2 years ago
Daniel
You remind me of myself until recently. I knew just enough Access to frustrate myself.  I knew what I wanted to do and I knew just enough to try but not enough to make Things work. so finally, I started taking Richard's access courses from the beginning to the end.  Now programming in access turned from a frustration to our pleasure. I strongly recommend you invest the time and money to go through those courses, no one teaches access better than Richard.
Richard Rost  @Reply  
          
2 years ago

Sami Shamma  @Reply  
             
2 years ago
Richard
Modesty does not become you.

Lol

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/2/2026 3:44:43 AM. PLT: 1s