473,698 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display message on subform when underlying query is empty

5 New Member
My main form has several subforms which display the results of queries.

I want to display a message in a subform when it's query is empty indicating that there are no records meeting the form's criteria.

wondering how this can be done.

Thanks

Erik
Dec 22 '10 #1
8 6609
Erik Pen
5 New Member
Anyone? It really can't be that hard?
Dec 23 '10 #2
mshmyob
904 Recognized Expert Contributor
Probably. IS the subform a datasheet view or continuous view.

cheers,
Dec 23 '10 #3
Erik Pen
5 New Member
Hi mshmyob

The subforms are continuous forms with headers.

Any help is appreaciated!
Dec 23 '10 #4
mshmyob
904 Recognized Expert Contributor
What is the query of one of your subforms.

cheers,
Dec 23 '10 #5
Rabbit
12,516 Recognized Expert Moderator MVP
There are multiple ways of doing this.

If the subforms are not linked to the recordset on the parent form, then when the parent form loads, you check the record count of the queries and either point the subform to another form with a message or hide the subform and unhide a textbox with the message.

Or you could, in the subforms, in their load event, check the record count of their queries and then hide the detail and unhide a message.

If the recordsets are linked, then you would move the code to the on current event of the parent form.
Dec 23 '10 #6
mshmyob
904 Recognized Expert Contributor
I did it with a simple check in the On Current event of the main form.

I created a label in the header of the subform call lblNoRecords and set the visible property to No.

Expand|Select|Wrap|Line Numbers
  1. If IsNull(Forms!frmYourMainFormName.YourSubformName.Form.ServerID) Then
  2.     Forms!frmYourMainFormName.YourSubformName.Form.lblNoRecords.Visible = True
  3. Else
  4.     Forms!frmYourMainFormName.YourSubformName.Form.lblNoRecords.Visible = False   
  5. End If
  6.  
Now as you scroll through the main form the subform will check for a null value in the primary key of the subform data and if it is null the label in the header will become visible or else it will be hidden.

Remember to change all form names and control names.

cheers,
Dec 23 '10 #7
Erik Pen
5 New Member
Thanks. I was trying exactly that (label in the header of the subform - except that I was trying the on open of the sub form. The IsNull never worked, i.e. it displayed whether null or not. I will try on the parent form.

thanks for your help. It is a bit more complicated because when my main form opens, it displays some sub forms while hiding others based on the tag property of the subform. I guess I can try to work this in as well!

I appreciate the help.
Dec 23 '10 #8
Erik Pen
5 New Member
Actually, I am afraid it wont work as I hoped. The way the form is set up is to look like a tabbed folder. The tabs are labels are in the form header and depending on which you click, displays different subforms. Therefore, I can't set the "empty query" label to visible if I am setting the form no not visible. I suppose I may be able to work something into the label's click event.

Here is the parent form On Open event -

Private Sub Form_Open(Cance l As Integer)

Dim ctlCurr As Control

For Each ctlCurr In Me.Controls
If ctlCurr.Tag = "GrpExposur e" Or ctlCurr.Tag = "GrpTabs" Or ctlCurr.Tag = "GrpDefault " Or ctlCurr.Tag = "Tabs" Then
ctlCurr.Visible = True
Else: ctlCurr.Visible = False
End If
Next ctlCurr



Me.lblExposure. BackColor = 16771305
Me.lblDelinquen cy.BackColor = 15377561
Me.lblRatings.B ackColor = 15377561
Me.lblCoverage. BackColor = 15377561

DoCmd.Maximize

End Sub
Dec 23 '10 #9

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

Similar topics

2
5776
by: Smartin | last post by:
Using Access 97 I am trying to create a form that allows for user entry of search terms and displays a table of results. I thought I could accomplish this using a subform but it isn't quite doing what I want it to do. What I have so far: Fields to enter search terms Subform bound to a query
1
3278
by: Crazy Cat | last post by:
Hi, whenever the underlying query being called by EXEC in the following has an empty result set I get the following error -- Invalid Data for 'Numeric' when EXEC returns empty row. However if I call the query without using REPLACE (which I'm forced to do, because openquery does not allow variables), I get just an empty result set. Whenever the underlying query returns a non-empty result set, the code works without error (regardless of...
1
1851
by: Macbane | last post by:
Hi There, I have a main form that with a subform which is based on a parameter query. I have 2 controls on the main form & which are used as parameters in the query. It all works fine and dandy until the query returns no records. The main form just "whites out" (probably due to the background coulor set to white!) when I get no records. I have coded and error message in the subform for when no records are returned and that doesn't...
10
3674
ChaseCox
by: ChaseCox | last post by:
I am using Access 97 to build my Database. I would like when my query is run, to populate a graph from the results of the query. Currently I am using a form to populate the query, and the query is then displaying the resulting records into a datasheet view on a subform. It is the resulting records I would like displayed on the graph. The fields I want on the graph are Prod_Code and Claim_Date. Thanks for the help.
4
2043
by: rczuba | last post by:
Problem: Creating a Default Value for a field in a subform when a field in the subform & form match. I'm trying to create a payroll database for a small home business that I have that has had (and hopefully will continue to have) lots of growth. I have created a Transaction table to hold the hours, date, location of work (as the employees work at various locations), pay rate, and employee id. the employee id field has a one-to-many...
8
2066
by: crazyhouse | last post by:
I am using the following code on a search page. myvalue = InputBox("Please enter the Tracking Number.") stDocName = "Inspection_form" stLinkCriteria = "=" & "'" & & "'" DoCmd.OpenForm stDocName, , , stLinkCriteria, acReadOnly What i would like to know is how to open another form or msgbox if the does not exist as a record.
1
1763
by: Crombam | last post by:
Hi to all, After searching the net for a couple of hours I just have to ask the question. How can I close a report with a subform (Pivot Chart) when this Pivot Chart is having no data? Explenation: I have a report, which displays a Pivot Chart (Subform). When clicking a command button for displaying this report a form pop-up wil appear, where one can select a dynamic date range. In this pop-up form I included a Cancel button. When the...
6
1697
by: phill86 | last post by:
Hi I have a report with an underlying query. The criteria in the query points to three different controls on a form. The user has to select client name, start date and end date. I want to be able to let the user select just the client name, and not the start and end dates, then run the report, as well as selecting client name, start and end date. Is this possible? Regards Phill SELECT T_ClientDetails.ClientID AS...
5
5544
by: phill86 | last post by:
Hi, I have a form that I have applied a filter to by using combo boxes which works fine. Is there a way to apply that filter to the forms underlying query Here is the code that I use to filter the form On Error GoTo Error_EquipFilter
0
8674
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
9026
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
7723
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...
1
6518
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3045
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
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
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.