Query Results In Form, But What If Query Is Null?

Aug 30, 2005

I have a query that displays results in a form, but if the query is null, I want to display a different form, or just an error message that says something like "your query returned no results" (right now it will display the form with no fields)

I am a beginning Access/VBA user and have searched and browsed the forum for combinations of null/query/form, but haven't found what I need. Can anyone point me in the right direction?

Thanks for any help.

View Replies


ADVERTISEMENT

Queries :: Join Results Of Unmatched Query With Matched Query To Include Null

Mar 24, 2013

I am trying to do the good 'ol sales report (query) to include customers with no sales.

I have a customers table, account number table, sales table & sales (line) detail table. (all linked in that order)

If I run a query to show customers (in the customer table) with account numbers, that works

An unmatched query to show customer without an account number works (but of course the unmatched account number field isn't shown).

How can I get the two two be shown together with the "unmatched" having a null or 0 for their account number?

I am guessing in principle, the resulting solution can be modified to show customers without sales alongside those with sales?

View 3 Replies View Related

Queries :: Forcing Query To Show Null Results

Jan 16, 2015

I have a query that is search for fields in a table that are either

1 - High
2 - Medium
3 - Low

I have a query that counts these and then puts the results into pie charts on a report.

However, when there is no "1 - High" value in the table against a paricualr criteria, obviously the quiery has nothing to look for an does not show a 0 value against the criteria but simply omits it (correctly) form the results.

This does affect the pie charts though which I want to show red for High, yellow for Medium and green for Low.

Therefore I need the query to show all criteria search results include 0 values, or to understand how I can colour code the series rather than the segments on the report.

View 1 Replies View Related

Create Error Message For Form Search Results Being Null

Sep 21, 2012

I have a form and when it's opened you get 3 different search questions to answer or leave blank. My question is.... If a search parameter is entered but no results are found to match it, how do I create an error message telling the requestor "No Data Found"?

View 7 Replies View Related

Ignoring Null Values From Form In Query

Mar 21, 2006

I have a form with 4 different search fields used to query a table and limit results: Policy#, SSN, Credit_Amt, Debit_Amt. Any matching rows based on the search criteria are returned in a subform.

My problem is how to handle any fields where the user doesn't specify a search value.

In my query, I have the Criteria set to:
Field: Policy_No
Criteria: =[Forms]![form name]![Policy#]

Field: SSN
Criteria: =[Forms]![form name]![SSN]

and so on....

If I place my criteria on different OR lines, the query runs, but if a user specifies more than 1 criteria, I get all the data for one criteria(such as policy# matches) and all the data for the second criteria(such as all the records for a certain credit_amt, regardless of Policy #).

If I place my criteria on the same criteria line, effectively making it AND, I get no results because I assume the database is looking for any blank search field values.

So, how do I make the query an "AND" query, but actually get results by ignoring any NULL search fields? So if a user enters a Policy# and Credit_Amt, the results will be only matching rows by Policy# AND Credit_Amt, and doesn't look at SSN and Debit_Amt.

I've tried different iterations using IIF(Not IsNull(.... to no avail.

Thanks!

View 3 Replies View Related

Displaying Query Results In A Form...

Jun 17, 2006

I have created a Query to search for clients in my database, the query and the search all work fine, however it would be nice to have the query post the results into a form I have created to display clients data rather than posting the results in a tables view.

Is there anyway todo this?

Thanks in advance.

View 1 Replies View Related

How To Open Results Of A Query In A Form?

Apr 17, 2007

Hello. I have a problem which has me stymied. I have created a Query-by-Form in which the criteria for the query is two combo boxes. I had no problems setting that up, but I want to display the results of this query in another form. I know this is possible, but do I need code for this? Any help/suggestions would be greatly appreciated!

View 3 Replies View Related

Fill Form With Query Results

Feb 24, 2005

In the attached db (both 2K and 97 ver) there is one form. Fill in the Date with 12/01/04 and the Start with 12/01/04 and Stop with 12/31/04. Press the Run Query button. The query is displayed...

How can I do it so on button press the form is filled with the query results?

View 1 Replies View Related

Return The Query Results On The Form

Sep 13, 2005

Hi,
I am not much familiar with VB Coding.Can any body please help me with this Please:When i click on submit button,it has to show the query results on the Form.Please find the below code:

Private Sub Command_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
Set db = CurrentDb
strSql = "SELECT Interface.[Interface ID], Interface.[Interface Name] from [Interface]"
Set rs = db.OpenRecordset(strSql)

Do While Not rs.EOF
Debug.Print ("Interface ID: " & rs![Interface ID] & "Interface Name: " & rs![Interface Name])
rs.MoveNext
Loop
rs.Close
db.Close
End Sub

#######################
It is not retrieving any thing.IF my code is wrong,Please advice me with the necessary steps to view the results on the form,when we clicl on the submit button.
Thanks,
Kanuri

View 3 Replies View Related

Displaying Query Results In Form

Sep 13, 2006

Forgive me for what may sound like a dum question -- Access is completely new to me.

I have my table. I have this displayed as a form.

At the bottom of the form, I have a text box and a command button.

The user enters in a key value. The command button triggers a macro that runs a query.

Now, I'd like the form to display the data returned from the query. How?

I tried creating a new form with its Record Source set to the query. I had the macro close the original form, run the query and open the new form. But before the new form could be opened, Access prompted me for a 'parameter value' (I assume so that the query could be run again).

What am I doing wrong?

View 3 Replies View Related

Displaying Results Of SQL Query On Form

Dec 15, 2006

I searched the archives and Access Help and couldn't quite find the answer to this question, which is no doubt simple.

I have a form showing Projects with an embedded subform showing all the Buildings associated with a given project. In the form footer section of the subform, I would like to display summary information about the buildings in the project being displayed, such as count of buildings, count of residential buildings, count of commercial buildings, and so on, and I would like these summary values to update as users add or change building information.

I know how to write the SQL query to pull this information, but do I use a text box or some other vehicle to do this? Using a text box as a calculated control, I was able to produce the count of buildings using:

= COUNT([UnitID])

To get the count of residential buildings, I need to be able to specify "WHERE bldgtypeID = 'R'"...I can't get the text box to display results of an SQL statement. Can text boxes handle SQL statements?

I really appreciate any suggestions you have.

View 10 Replies View Related

Transferring Query Results From One Form To Another

Aug 27, 2004

I have one table of records that I would like to query and display the results.
I have created a form that asks the user for criteria for the query (search).
Then I want to display the results from that query in another form (results).
The problem is that I cannot figure out how to do it.

The results form is using the query as its source. I have tried running the
search and then opening the results form, but I get a message saying that
I tried to lock the table but it was in use.

Is there a way to link these forms so that i can bring up the search form,
perform the search, and have the results brought up in the results form?

Thanks for the help.

View 4 Replies View Related

Form Using Dynamic Query Results

Apr 29, 2006

Hi, hope this is a reasonable thing for semi-beginner to intermediate person to do.

Our MS Access 2000 db shared on a server stores projects, categories of projects, clients, contractors doing the projects. Contractors are offered projects within their chosen categories based on their order on the list (last company who was offered a contract goes to bottom of list, like that).

Currently we print out a phone list of the contractors (in desc. date order of the most recent offer accepted or refused), then we phone down the list until someone accepts. Later we enter all those offers in order on frmOffers to store the date & time stamp of that offer.

Problem is, several contracts can be on offer on a given day, so when a company accepts/declines Project A, that company is still showing as high on the (paper) list for Project B. So when we have 3 people phoning they don't know they've offered multiple contracts to the same company this morning.

Is it possible for a form "Offers" to be based on a query that keeps updating like that? For example, you open frmProject to display details of a certain Project, cmd button to open frmOffers (continuous form, showing all offers so far with company, phone #, "accept"/"decline" & date/time stamp). Then, when you tab to the next record, can you have it show which company is next in line (even as the person beside you has updated their frmOffers in the meantime)?

Would you need to have a separate table storing only the most recent offer for each company? If so, how would you get that updated all the time?

Anything you could offer to point me in the right direction would be very much appreciated!!

Thanks,

View 1 Replies View Related

Displaying Query Results In A Form

Feb 26, 2008

Hi everyone,

I have a query which totals the amount of all invoices for a specific project number. I would like to take this total and have it displayed on the form from where overall project information is inputed.

Right now I have a table which shows general project information and a table showing invoice infomation (linked to the general table via a project #)

I also have two forms, one for general info and there's a button which opens the invoice form. When the invoice form opens, it opens an invoice with the corresponding project number shown on the general form. I would like the total invoice amount (from the query) displayed on the corresponding general form.

ex: in the general form for project# 100, I click invoice once and enter $50, I click invoice again and enter $100. The query automatically shows a total of $150 for project# 100. I would like this $150 displayed on the general form for quick reference.

Thanks for all the help

View 1 Replies View Related

Complex Query/form Results Unexpected

May 16, 2006

I've got a query pulling data from a view I created that gives all the data I need. The query gets it's criteria from a form with 10 combo boxes, a radio box with 3 options and 2 date fields for the timeframe to run the report in.

The issue:
over half the columns of data that the radio buttons can limit results by have null values but only two of the columns are excluding records where the values in them are null. As any combination of the combo boxes are null I'm using the following format for my criteria per column
IIf(IsNull([Forms]![Margin Dialog]![InstallerOption]),[Installer_from_Web],[Forms]![Margin Dialog]![InstallerOption])
That is an example of a column that works, the following is a column that is excluding null values no matter what I do
IIf(IsNull([Forms]![Margin Dialog]![AOIOption]),[ProductType],[Forms]![Margin Dialog]![AOIOption])
I am not seeing the error and could use some thoughts.

View 13 Replies View Related

Pop Message In Form Based On Query Results

Jan 12, 2006

G'Day:

I have tried numerous things to try and create a pop up message or form to alert users of a timing conflict in a scheduling program.
I am not real familiar with codes and am not sure how to handle this.

I used Jason Browne's web site to help me construct a query that will list a result of time conflicts (ie some project is scheduled to occur before another one is completed).
What I need to have happen is the alert message or form opens when this conflict occurs but does nothing when the timing is ok.

I am not very familiar with code and am having a road block mentally. All help is appreciated!

THANKS

View 3 Replies View Related

Show Count Query Results On Form

Jan 24, 2006

I have a form that I am trying to show in a text box the results of a count query. The query has two fields in which one is a check box. The criteria for the text box field is set to true to list all that are checked. I want the query to show all the records that are true. This works if I run the query, but the result isn't showing in my text box on the form. On the form text box properties in Control source I have =DLookUp("[Run Number]","Control Room Drumctqry"). Run Number is the field that I am counting, Control Room Drumctqry is the query. Any idea as to what I am doing wrong?
Thanks,

View 7 Replies View Related

Show Count Query Results On Form

Jan 24, 2006

I have a form that I am trying to show in a text box the results of a count query. The query has two fields in which one is a check box. The criteria for the text box field is set to true to list all that are checked. I want the query to show all the records that are true. This works if I run the query, but the result isn't showing in my text box on the form. On the form text box properties in Control source I have =DLookUp("[Run Number]","Control Room Drumctqry"). Run Number is the field that I am counting, Control Room Drumctqry is the query. Any idea as to what I am doing wrong?
Thanks,

View 1 Replies View Related

Display Query Results On Form Via Text Box

Aug 27, 2004

Hi,
I have created a form (Form1) based on a table (Table1) and also a Query based on this table (Query1). I calculate a field in the query (Expr1: [column1] + [column2])
Now i have created a text box on Form1 that should display Expr1.
I know I could also calculate the value directly via the expression builder, but I would prefer to simply display Expr1 from my query. Which is the syntax I have to use in the Expression Builder?
I tried "= [Query1]![Expr1]" but it does not work.
Thanks for your help
Tigrou

View 3 Replies View Related

Forms :: Display Query Results In A Form

Jul 25, 2014

I am trying to allow end-users to only use buttons to navigate and display records in my database (so they don't know access is in the background) I have query that runs when they press a button but after they run it there is no way to get back to the main interface screen i.e. there is not a place to put another button and close the query. I was looking into creating a form to display the query results in datasheet view but it is not appearing the way I want. I inserted a subform and the results got better but I also do not like the way it displays because the user can see the subform, simple solution to get my data to display in the form so a user can view the results similar to datasheet view?

View 3 Replies View Related

Forms :: How To Sort Query Results With A Form

Aug 14, 2013

Essentially I have a table for rooms around my school and what the rooms contain. Most of the details for the rooms are Boolean (e.g. If the room has a projector, Yes/No).

So what I am trying to do is have a form where i can select a checkbox(s) and if i tick one, a query that holds all the room details will only show rooms with projectors in them, which i can then display those results in another form.

My question is how do I get the check boxes in the form to narrow down the room results to only show the ones with the criteria i have selected in the form?

View 1 Replies View Related

Forms :: Query From Form To Return All Results

Jan 6, 2014

I have a form that displays multiple records in datasheet view. I want to query off of that form and return all results for all records being displayed. However, I'm not sure how to tell Access to do this. Access instead wants to return records for only the first displayed record in the form or the record that is highlighted by the cursor.

In the attached image you can see a list of AccountingUnits (AU) going down. My query using AU from the form as criteria will only return records for AU 114510 since it is the first record, but I would like to see records for all AU's being displayed by the form. How can I do this?

View 13 Replies View Related

Display Query Results On User Form?

Dec 27, 2013

I have created form and would like to display query results on form (in textbox), which is executed based on combobox change event on the same form.

View 3 Replies View Related

Filter Query Results By Date Range In Form

Jan 3, 2006

I have a query form that allows user to search by two criteria (in which, user can select "And" or "Or" clause for the two criteria). I also allow user to filter the results by date range. On the form, I have two command button, one will prompt the results in a query table, and the other will prompt a report.

Problem 1
I manage to prompt report with a date range (i.e. two unbound text boxes for start date and end date). But, I dont' manage to disable the filter if the date range is null. Below is the code for this report command button. Should I use a toggle button to make a select case?

Private Sub cmdReport_Click()
Dim varItem As Variant
Dim strDocName As String
Dim str1MainCate As String
Dim str2MainCate As String
Dim str2MainCateCondition As String
Dim strDate As String
Dim strSQL As String
Dim strFilter As String
' Build criteria string for 1st ComboBox
For Each varItem In Me.fstMainCate.ItemsSelected
str1MainCate = str1MainCate & ",'" & Me.fstMainCate.ItemData(varItem) & "'"
Next varItem
If Len(str1MainCate) = 0 Then
str1MainCate = "Like '*'"
Else
str1MainCate = Right(str1MainCate, Len(str1MainCate) - 1)
str1MainCate = "IN(" & str1MainCate & ")"
End If
' Build criteria string for 2nd Combo Box
For Each varItem In Me.SecMainCate.ItemsSelected
str2MainCate = str2MainCate & ",'" & Me.SecMainCate.ItemData(varItem) & "'"
Next varItem
If Len(str2MainCate) = 0 Then
str2MainCate = "Like '*'"
Else
str2MainCate = Right(str2MainCate, Len(str2MainCate) - 1)
str2MainCate = "IN(" & str2MainCate & ")"
End If
' Get 1toggle button condition
If Me.optAnd2MainCate.Value = True Then
str2MainCateCondition = " AND "
Else
str2MainCateCondition = " OR "
End If
' Build SQL statement
strSQL = " SELECT NewsClips.IssueDate, NewsClips.Title_Eng, NewsClips.Titile_Chi, NewsClips.NewsSource, NewsClips.[1CategoryMain], NewsClips.[1Sub-Category], NewsClips.[2CategoryMain], NewsClips.[2Sub-Category], NewsClips.hyperlink, NewsClips.FirstTwoPara, NewsClips.Notes, NewsClips.attachment FROM NewsClips " & _
"WHERE NewsClips.[1CategoryMain] " & str1MainCate & _
str2MainCateCondition & "NewsClips.[2CategoryMain] " & str2MainCate & ";"
' Build criteria string for Date
If Not IsNull(Me![dateTo]) Then
strDate = strDate & " NewsClips.IssueDate Between #" + Format(Me![datefrom], "mm/dd/yyyy") + "# AND #" & Format(Me![dateTo], "mm/dd/yyyy") & "#"
'Format(Me.dateTo, "mm/dd/yy")
Else
strDate = strDate & " NewsClips.IssueDate >= #" + Format(Me![datefrom], "mm/dd/yyyy") + "#"
End If
' filter string
strFilter = strDate
' Open report
strDocName = "RptCateDateQry"
DoCmd.OpenReport strDocName, acViewDesign, , strFilter
With Reports(strDocName)
.RecordSource = strSQL
.Filter = strFilter
.FilterOn = True
End With
DoCmd.Save acReport, strDocName
DoCmd.OpenReport strDocName, acViewPreview
Exit_cmdReport_Click:
End Sub

Problem 2
I have no idea how to filter the query results by date range in the query table. Below is the code of the query table button, which do not offer the filter feature. Would really appreciate it if you can give me some advice.

Private Sub cmdOK_Click()
On Error GoTo cmdOK_Click_Err
Dim blnQueryExists As Boolean
Dim cat As New ADOX.Catalog
Dim cmd As New ADODB.Command
Dim qry As ADOX.View
Dim varItem As Variant
Dim strDate As String
Dim str1MainCate As String
Dim str2MainCate As String
Dim str1MainCateCondition As String
Dim str2MainCateCondition As String
Dim strSQL As String
' Check for the existence of the stored query
blnQueryExists = False
Set cat.ActiveConnection = CurrentProject.Connection
For Each qry In cat.Views
If qry.Name = "QryCateDateForm" Then
blnQueryExists = True
Exit For
End If
Next qry
' Create the query if it does not already exist
If blnQueryExists = False Then
cmd.CommandText = "SELECT NewsClips.IssueDate, NewsClips.Title_Eng, NewsClips.Titile_Chi, NewsClips.NewsSource, NewsClips.[1CategoryMain], NewsClips.[1Sub-Category], NewsClips.[2CategoryMain], NewsClips.[2Sub-Category], NewsClips.hyperlink, NewsClips.FirstTwoPara, NewsClips.Notes, NewsClips.attachment FROM NewsClips"
cat.Views.Append "QryCateDateForm", cmd
End If
Application.RefreshDatabaseWindow
' Turn off screen updating
DoCmd.Echo False
' Close the query if it is already open
If SysCmd(acSysCmdGetObjectState, acQuery, "QryCateDateForm") = acObjStateOpen Then
DoCmd.Close acQuery, "QryCateDateForm"
End If
' Build criteria string for Date
If Not IsNull(Me![dateTo]) Then
strDate = strDate & " NewsClips.IssueDate Between #" + Format(Me![datefrom], "mm/dd/yyyy") + "# AND #" & Format(Me![dateTo], "mm/dd/yyyy") & "#"
'Format(Me.textStartDate, "mm/dd/yy")
Else
strDate = strDate & " NewsClips.IssueDate >= #" + Format(Me![datefrom], "mm/dd/yyyy") + "#"
End If

' Build criteria string for 1MainCate
For Each varItem In Me.fstMainCate.ItemsSelected
str1MainCate = str1MainCate & ",'" & Me.fstMainCate.ItemData(varItem) & "'"
Next varItem
If Len(str1MainCate) = 0 Then
str1MainCate = "Like '*'"
Else
str1MainCate = Right(str1MainCate, Len(str1MainCate) - 1)
str1MainCate = "IN(" & str1MainCate & ")"
End If
' Build criteria string for 2MainCate
For Each varItem In Me.SecMainCate.ItemsSelected
str2MainCate = str2MainCate & ",'" & Me.SecMainCate.ItemData(varItem) & "'"
Next varItem
If Len(str2MainCate) = 0 Then
str2MainCate = "Like '*'"
Else
str2MainCate = Right(str2MainCate, Len(str2MainCate) - 1)
str2MainCate = "IN(" & str2MainCate & ")"
End If
' Get 1MainCate condition
If Me.optAnd1MainCate.Value = True Then
str1MainCateCondition = " AND "
Else
str1MainCateCondition = " OR "
End If
' Get 2MainCate condition
If Me.optAnd2MainCate.Value = True Then
str2MainCateCondition = " AND "
Else
str2MainCateCondition = " OR "
End If
' Build SQL statement
strSQL = " SELECT NewsClips.IssueDate, NewsClips.Title_Eng, NewsClips.Titile_Chi, NewsClips.NewsSource, NewsClips.[1CategoryMain], NewsClips.[1Sub-Category], NewsClips.[2CategoryMain], NewsClips.[2Sub-Category], NewsClips.hyperlink, NewsClips.FirstTwoPara, NewsClips.Notes, NewsClips.attachment FROM NewsClips " & _
"WHERE NewsClips.[1CategoryMain] " & str1MainCate & _
str2MainCateCondition & "NewsClips.[2CategoryMain] " & str2MainCate & _
str1MainCateCondition & strDate & ";"
' Apply the SQL statement to the stored query
cat.ActiveConnection = CurrentProject.Connection
Set cmd = cat.Views("QryCateDateForm").Command
cmd.CommandText = strSQL
Set cat.Views("QryCateDateForm").Command = cmd
Set cat = Nothing
' Open the Query
DoCmd.OpenQuery "QryCateDateForm"

' If required the dialog can be closed at this point
' DoCmd.Close acForm, Me.Name
' Restore screen updating
cmdOK_Click_Exit:
DoCmd.Echo True
Exit Sub
cmdOK_Click_Err:
MsgBox "An unexpected error has occurred." _
& vbCrLf & "Procedure: cmdOK_Click" _
& vbCrLf & "Error Number: " & Err.Number _
& vbCrLf & "Error Description:" & Err.Description _
, vbCritical, "Error"
Resume cmdOK_Click_Exit
End Sub


Sorry for posting this question again, as I thought it's better to make it a seperate posting, rather than a reply to my early post. Your advice will be greatly appreicated.

View 1 Replies View Related

Use Query Results OnLoad Of Form To Conduct An Action

Jan 2, 2008

Alright. I've tried searching, but to be honest, I'm not even sure what to search for.

I want to create some VBA that onLoad of the opening form of the database, it will take info from a query that looks for data entered for a student. It will be looking to see if there is data in two date fields. If it finds data in both fields, then I want to make a change to the EnrollmentID row of another table to changed the graduated column from No to Yes.

To expand on that, I'll want to check each ClassID row and if all of the associated students of that class have the column Graduated checked as yes, it will place the date in the date column for that particular class.

This is essentially my way of auto-archiving data as the combo box selections on my forms don't allow for class data to be shown if there is a Closed Date entered for the class and you won't be able to enter more test results for a student if the Graduated Column is checked in the Enrollment table (associates memberID, ClassID, CourseID into a single table)

Any insight on how to do this would be greatly apprecaited.

View 6 Replies View Related

Auto Fill Form From Query Results With Button

Feb 28, 2005

Hi all,
I've got another one for ya... I did a search, but must be choosing poor keywords because I can't find the answer I'm seeking.
Anyhoo, what I need to do is use a bit of information garnered from a database to fill in a line of fields on a form at the click of a button on a different database.
I have linked the table I need from the first database, and created the query that grabs the information I need to autofill. So far, so good. What I can't figure out is how to get this information to pop into the fields I want to fill.
I'd like to use a button with a click event to pass the data into each appropriate box (there would be 5 fields worth of info). I need to use a button because it won't always fill in the same line, which of course, adds to the complexity.
Can anyone point me in the right direction?
Thanks in advance,
Ceejay

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved