473,383 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

'Show all results' row within combo possible?

50
Hi guys, have searched for this but can't find an answer...

I have a number of combo boxes that limit a continuous subform in the header of the main form.

Currently, if they are blank, all results are shown due to the following code in my underlying query:

((Tbl_Schedule.Machine)=Forms!Frm_Schedule!ComboMa chine Or Forms!Frm_Schedule!ComboMachine Is Null)

Is there any way of having a 'show all results' row in each of my combo boxes so that this can be selected and all results shown?

Hope you can help, OllyJ
Jan 28 '08 #1
17 1923
NeoPa
32,556 Expert Mod 16PB
If the ComboBoxes are currently populated from a table then that would be difficult.
I suppose you could use a UNION query in the RecordSource, but simpler would probably be for the operator simply to clear the ComboBox, thus returning a Null value. Your code could handle this.
Jan 28 '08 #2
OllyJ
50
Thank you for your timely response!

Sorry to be a pain but if you could explain the code required for a union query (never used one before), that would be great.

I can then always resort back to the null value if my coding gets too complicated.

Many thanks, OllyJ
Jan 28 '08 #3
NeoPa
32,556 Expert Mod 16PB
Is it general usage of a UNION query (syntax) or specifics you need?
Bear in mind I can't help with specifics without some indication or examples of what you're doing currently.
Jan 28 '08 #4
OllyJ
50
Specifics really if you don't mind...

Here is some information that might help: (if you need me to attach a file get back to me and i'll get it right over)

Qry_Schedule is the underlying recordsouce for a continuous subform within the details section of 'Frm_Schedule' and all of the Combos shown in code below are effectively "limiters" within the header of 'Frm_Schedule'. The limiters have code 'after update' to limit the results within the continuous subform.

Qry_Schedule:

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT Tbl_Schedule.AddedDate, Tbl_Schedule.Day_Night, Tbl_Schedule.Machine, Tbl_Schedule.Machine_Arm_Head, Tbl_Schedule.Job_No, Tbl_Schedule.Stock_Code, Tbl_Schedule.Tool_No, Tbl_Schedule.Operator, Tbl_Schedule.QP, Tbl_Schedule.QA, Tbl_Schedule.QScrap
  2.  
  3. FROM Tbl_Schedule
  4.  
  5. GROUP BY Tbl_Schedule.AddedDate, Tbl_Schedule.Day_Night, Tbl_Schedule.Machine, Tbl_Schedule.Machine_Arm_Head, Tbl_Schedule.Job_No, Tbl_Schedule.Stock_Code, Tbl_Schedule.Tool_No, Tbl_Schedule.Operator, Tbl_Schedule.QP, Tbl_Schedule.QA, Tbl_Schedule.QScrap
  6.  
  7. HAVING (((Tbl_Schedule.AddedDate) Between Forms!Frm_Schedule!LimitFromDate And Forms!Frm_Schedule!LimitToDate) And ((Tbl_Schedule.Day_Night)=Forms!Frm_Schedule!Day_Night Or Forms!Frm_Schedule!Day_Night Is Null) And ((Tbl_Schedule.Machine)=Forms!Frm_Schedule!ComboMachine Or Forms!Frm_Schedule!ComboMachine IS NULL) And ((Tbl_Schedule.Machine_Arm_Head)=Forms!Frm_Schedule!ComboArmHead Or Forms!Frm_Schedule!ComboArmHead Is Null) And ((Tbl_Schedule.Stock_Code)=Forms!Frm_Schedule!ComboStockCode Or Forms!Frm_Schedule!ComboStockCode Is Null) And ((Tbl_Schedule.Tool_No)=Forms!Frm_Schedule!ComboToolNo Or Forms!Frm_Schedule!ComboToolNo Is Null) And ((Tbl_Schedule.Operator)=Forms!Frm_Schedule!ComboOperator Or Forms!Frm_Schedule!ComboOperator Is Null))
  8.  
  9. ORDER BY Tbl_Schedule.AddedDate;
Each limiter has its own row source query to prevent multiple entries.

Everything worked until i tried this code for the machine row source query:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT Qry_Schedule.Machine FROM Qry_Schedule
  2. UNION SELECT "(All)" As Machine FROM Qry_Schedule;
...in this instance... 'All' is an option within the combo, along with the other machines, but when selected it returns no results, instead of the results for every machine.

It is probably something obvious, hope you can help... OllyJ
Jan 28 '08 #5
NeoPa
32,556 Expert Mod 16PB
From the Access 2K Help system :
Combine data in fields from two or more tables using a union query
Union queries combine corresponding fields from two or more tables or queries into one field. When you run a union query, it returns the records from corresponding fields in the included tables or queries.

In the Database window, click Queries under Objects, and then click New on the Database window toolbar.

In the New Query dialog box, click Design View, and then click OK.

Without adding tables or queries, click Close in the Show Table dialog box.

On the Query menu, point to SQL Specific, and then click Union.

Enter SQL SELECT statements combined with either the UNION operation if you don't want to return duplicate records or the UNION ALL operation if you do want to return duplicate records.
Note Each SELECT statement must return the same number of fields, in the same order. The corresponding fields are required to have compatible data types with one exception: You can use a Number and a Text field as corresponding fields.

This UNION query combines the values in the CompanyName and City fields from the Supplier & Customer tables where the Country field is 'Brazil'
Expand|Select|Wrap|Line Numbers
  1. SELECT [CompanyName],[City]
  2. FROM [Supplier]
  3. WHERE [Country]='Brazil'
  4. UNION SELECT [CompanyName],[City]
  5. FROM [Customer]
  6. WHERE [Country]='Brazil'
** Edit **
This is not in response to your last post (#5) but was prepared before I saw it.
Jan 28 '08 #6
NeoPa
32,556 Expert Mod 16PB
Specifics really if you don't mind...
It is probably something obvious, hope you can help... OllyJ
I will have a look for you. A lot to look through though, so you may need to wait a bit.
Jan 28 '08 #7
NeoPa
32,556 Expert Mod 16PB
Before I manage to get that done (looks very complicated with all that SQL and all the form references) I'll just post some SQL that I've managed to knock up which will do essentially what you originally asked for.
Expand|Select|Wrap|Line Numbers
  1. SELECT Acronym
  2. FROM tblAcronym
  3. UNION SELECT Acronym
  4. FROM (SELECT DISTINCT '(All)' AS Acronym
  5. FROM tblAcronym)
  6. ORDER BY Acronym
This is to get the data out of one of my own tables.
NB. The subquery doesn't necessarily need to use the same table for this. Any quick and simple record source will do, though local and small Access tables work best.
Jan 28 '08 #8
NeoPa
32,556 Expert Mod 16PB
So, for the example you used earlier
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT Qry_Schedule.Machine FROM Qry_Schedule
  2. UNION SELECT "(All)" As Machine FROM Qry_Schedule;
Try instead :
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT [Machine]
  2. FROM [Qry_Schedule]
  3. UNION SELECT [Machine]
  4. FROM (SELECT DISTINCT '(All)' AS [Machine]
  5.       FROM [Qry_Schedule])
  6. ORDER BY [Machine]
It would probably make sense to replace the FROM clause in line #5 with one which refers to a small local table for performance reasons.
Jan 28 '08 #9
NeoPa
32,556 Expert Mod 16PB
Ooh err!!
I just realised that the subquery part was not why it worked :(
That bit was just overcomplicating it. It was the DISTINCT predicate that made the difference. Here is a revised version :
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT [Machine]
  2. FROM [Qry_Schedule]
  3. UNION SELECT DISTINCT '(All)' AS [Machine]
  4. FROM [Qry_Schedule]
  5. ORDER BY [Machine]
Jan 28 '08 #10
OllyJ
50
Thank you for your help NeoPa, having entered your revised code, it gives me the option to select 'All' from the combobox, however...

...it then limits the subform to no results. I think this has to do with my original underlying query containing the code:

((Tbl_Schedule.Machine)=Forms!Frm_Schedule!ComboMa chine Or Forms!Frm_Schedule!ComboMachine IS NULL)

I have the feeling I need to change is null to 'is 'all' effectively but am struggling with that coding. Any ideas?
Jan 29 '08 #11
OllyJ
50
...got it! Thanks again for your help NeoPa!

I had to change the original query code to:

((Tbl_Schedule.Machine)=Forms!Frm_Schedule!ComboMa chine Or Forms!Frm_Schedule!ComboMachine='(All)') instead of IS NULL

and then 'on load' set each combo by using:

me.combomachine = "(All)"

..works perfectly!
Jan 29 '08 #12
sierra7
446 Expert 256MB
Hi Guys
Sorry to join in late. That is certanly one way to 'skin the cat' but this is easy too;

I similarly use combo boxes to set-up filters for forms. This example just selects 'Customer Name' from a combo box on two columns,
Expand|Select|Wrap|Line Numbers
  1. Row Source = SELECT Customers.CustomerID, Customers.CompanyName FROM Customers;
The column width for CustomerID=0 (so the first visible column is CompanyName), the Bound Column = 2 (although it's an Unbound combo), and Limit to List = No.

The After Update event is then;
Expand|Select|Wrap|Line Numbers
  1. ' stCust is Public string
  2. If Trim([getSupp].Column(1)) = "" Or IsNull([getSupp].Column(1)) Then
  3.     stCust = ""
  4.     Me!getSupp = "All Customers"
  5. Else
  6.     stCust = "and [CustomerID]= " & [getSupp].Column(0)
  7. End If
  8.  
  9. DispDetails
So, initially the combo box says 'All Customers' (set by the On_Current event of the form: other combos are initailised accordingly) When a customer is selected their name appears in the combo-box and the 'stCust' element of the filter string is set; then the Sub 'DispDetails' concatonates all filter strings and sets the Filter (also filtering on produt codes and the like).

If the user then removes the entry from the combo (space, backspace or delete), the combo then again says 'All Customers' and the filter element is revised.

The advantage of NeoPa's solution is that 'All Customers' would appear as an option in the combo. A disadvantage would be that 'Aardvark Corpn' would appear before it! (another problem for another day!)

S7
Jan 29 '08 #13
NeoPa
32,556 Expert Mod 16PB
...got it! Thanks again for your help NeoPa!
...
...works perfectly!
That's great Olly :)

@Sierra7
Check out post #2 for my original suggestion. The eventual solution was what was required by the OP (OllyJ).
This isn't something I'd ever used myself, so I had to do a little research on it to find a way.
Jan 29 '08 #14
sierra7
446 Expert 256MB
That's great Olly :)

@Sierra7
Check out post #2 for my original suggestion. The eventual solution was what was required by the OP (OllyJ).
This isn't something I'd ever used myself, so I had to do a little research on it to find a way.
NeoPa
Sorry I missed that one. I think the word UNION poked me in the eye and then I went brain dead when I saw the OP's SELECT statement !
I just thought ,"Life's got to be easier than this".

I agree that it's not something to use all of the time but it sometimes helps new users to become accustomed to what they are doing. It's sometimes easier to explain they are filtering for ALL of something than NOT filtering for NONE.

S7
Jan 29 '08 #15
NeoPa
32,556 Expert Mod 16PB
LOL
That wasn't a criticism. I was just saying how I agreed with you :)
Jan 29 '08 #16
OllyJ
50
Don't want to start an argument! haha! Thanks again NeoPa for the help!

By the way, I have just added a new post re: the changing colour of a box depending on the specific result within a continuous form. I have been on it for a while ( ...don't want you lot to think I come across a problem and post it straight away!)

If you can help great, if not don't worry.
Jan 29 '08 #17
NeoPa
32,556 Expert Mod 16PB
A link always helps Olly ;)
Change colour of box within record of continuous form...
Jan 29 '08 #18

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

Similar topics

2
by: Maurice | last post by:
Hi does anyone know if it's possible in .NET to display a multicolumn list like in MSAccess? I'm building an application in which a user can enter a search text and the application will then show...
1
by: Donna Sabol | last post by:
I have a form (frm_MAIN_RPT) that contains a combo box (Combo6) & subform (dbo_REQ_subform). The combo box is used to select the "cost center" data that will be displayed in the subform. From...
4
by: d.p. | last post by:
Hi all, I'm using MS Access 2003. Bare with me on this description....here's the situation: Imagine insurance, and working out premiums for different insured properties. The rates for calculating...
3
by: Jimmy | last post by:
I use a combo box to filter the results of a form. Sql for combo box is... SELECT StatusPriority, Status FROM tblStatus UNION Select = 0 as AllChoice, "Show All" as Bogus From tblStatus ORDER...
1
by: Shawn Yates | last post by:
It has been a while since I have done anything on MS Access and I seem to be a bit rusty. I hope someone could help me solve my issue. I have a form that has multiple combo boxes on it. Each box...
8
by: boliches | last post by:
I am using MS Access 2000 and would like the results from a combo box to be filtered as you type a requirement into the combo box. EG. As you type the name "Smith" the results in the combo box will...
2
by: banderson | last post by:
Hello, I have a data entry form for a table with information about buildings and am having a problem making a combo box do what I want. I would like to make the combo box show a list of unique bldg...
3
by: WiscCard | last post by:
This seems simple enough, but I am having problems. I have a table of customer information. I have a form with various combo boxes displaying unique customer information (in this case, zone and...
16
by: dougmeece | last post by:
Good day everyone, I have a database with 2 main forms. The first form is used to add records to the database and contains a command button that opens the 2nd form for records searching. On...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.