Filtering Combo #2 from a value in Combo #1

Hi,

I have two Combo fields:

cmb1 (which has a choice of PROD / DEV)
cmb2 - I want to list dates associated either PROD or DEV.

I have this SQL for cmb1:

strSQL = "SELECT DISTINCT tbl01_FullCompare.ShutType, 
tbl01_FullCompare.ImpDate FROM tbl01_FullCompare WHERE 
tbl01_FullCompare.ShutType = "" & Me![cmbShutType] & "" ORDER BY 
tbl01_FullCompare.ImpDate;"

Me![cmbImpDate].RowSource = strSQL

However when I i select the cmbImpDate drop down box, there are no records 
listed... can anyone advise how to get this working?

Any assistance is always greatly appreciated...

Cheers,
GLT.
0
Utf
2/8/2010 2:21:01 AM
access.forms 6864 articles. 2 followers. Follow

6 Replies
858 Views

Similar Articles

[PageSpeed] 42

Your quotes are wrong. What you've got ends up with a SQL string

SELECT DISTINCT tbl01_FullCompare.ShutType, tbl01_FullCompare.ImpDate FROM 
tbl01_FullCompare WHERE tbl01_FullCompare.ShutType = " & Me![cmbShutType] & 
" ORDER BY tbl01_FullCompare.ImpDate;"

In other words, it's looking for the literal string " & Me![cmbShutType] & 
", whereas you want it to be looking for whatever's been selected in the 
combo box.

Change your code to

strSQL = "SELECT DISTINCT ShutType,  " & _
  "ImpDate FROM tbl01_FullCompare " & _
  "WHERE ShutType = """ & Me![cmbShutType] & _
  """ ORDER BY ImpDate;"

That's three double quotes in a row, as opposed to the two double quotes in 
a row that you have.

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"GLT" <GLT@discussions.microsoft.com> wrote in message 
news:8A3F546B-9487-482D-B850-0D48632E2E47@microsoft.com...
> Hi,
>
> I have two Combo fields:
>
> cmb1 (which has a choice of PROD / DEV)
> cmb2 - I want to list dates associated either PROD or DEV.
>
> I have this SQL for cmb1:
>
> strSQL = "SELECT DISTINCT tbl01_FullCompare.ShutType,
> tbl01_FullCompare.ImpDate FROM tbl01_FullCompare WHERE
> tbl01_FullCompare.ShutType = "" & Me![cmbShutType] & "" ORDER BY
> tbl01_FullCompare.ImpDate;"
>
> Me![cmbImpDate].RowSource = strSQL
>
> However when I i select the cmbImpDate drop down box, there are no records
> listed... can anyone advise how to get this working?
>
> Any assistance is always greatly appreciated...
>
> Cheers,
> GLT. 

0
Douglas
2/8/2010 2:58:10 AM
Just a stab at it but I'd try:

strSQL = "SELECT DISTINCT tbl01_FullCompare.ShutType, 
tbl01_FullCompare.ImpDate FROM tbl01_FullCompare WHERE 
tbl01_FullCompare.ShutType = '" & Me![cmbShutType] & "' ORDER BY 
tbl01_FullCompare.ImpDate;"




"GLT" wrote:

> Hi,
> 
> I have two Combo fields:
> 
> cmb1 (which has a choice of PROD / DEV)
> cmb2 - I want to list dates associated either PROD or DEV.
> 
> I have this SQL for cmb1:
> 
> strSQL = "SELECT DISTINCT tbl01_FullCompare.ShutType, 
> tbl01_FullCompare.ImpDate FROM tbl01_FullCompare WHERE 
> tbl01_FullCompare.ShutType = "" & Me![cmbShutType] & "" ORDER BY 
> tbl01_FullCompare.ImpDate;"
> 
> Me![cmbImpDate].RowSource = strSQL
> 
> However when I i select the cmbImpDate drop down box, there are no records 
> listed... can anyone advise how to get this working?
> 
> Any assistance is always greatly appreciated...
> 
> Cheers,
> GLT.
0
Utf
2/8/2010 3:19:01 AM
Appologies, I made an error in my previous post, the SQL mentioned below is 
the row source for cmb2.

I have now updated the SQL that gets set for the cmb2 rowsource to this:

strSQL = "SELECT DISTINCT tbl01_FullCompare.ShutType, 
tbl01_FullCompare.ImpDate " & _
         "FROM tbl01_FullCompare " & _
         "WHERE (((tbl01_FullCompare.ShutType) Like 
[forms]![frm01_ProcessErr]![cmbShutType]));"

The filtering works properly, and cmb2 displays the filtered dates correctly 
(based on the selection in cmb1) on the form.

However, but the actual value stored in cmb2 (which should be ImpDate), is 
actually ShutType - can anyone advise why it displays the correct Date value, 
but stores another value?  How can I fix this?

"GLT" wrote:

> Hi,
> 
> I have two Combo fields:
> 
> cmb1 (which has a choice of PROD / DEV)
> cmb2 - I want to list dates associated either PROD or DEV.
> 
> I have this SQL for cmb1:
> 
> strSQL = "SELECT DISTINCT tbl01_FullCompare.ShutType, 
> tbl01_FullCompare.ImpDate FROM tbl01_FullCompare WHERE 
> tbl01_FullCompare.ShutType = "" & Me![cmbShutType] & "" ORDER BY 
> tbl01_FullCompare.ImpDate;"
> 
> Me![cmbImpDate].RowSource = strSQL
> 
> However when I i select the cmbImpDate drop down box, there are no records 
> listed... can anyone advise how to get this working?
> 
> Any assistance is always greatly appreciated...
> 
> Cheers,
> GLT.
0
Utf
2/8/2010 3:19:01 AM
On Sun, 7 Feb 2010 19:19:01 -0800, GLT <GLT@discussions.microsoft.com> wrote:

>Appologies, I made an error in my previous post, the SQL mentioned below is 
>the row source for cmb2.
>
>I have now updated the SQL that gets set for the cmb2 rowsource to this:
>
>strSQL = "SELECT DISTINCT tbl01_FullCompare.ShutType, 
>tbl01_FullCompare.ImpDate " & _
>         "FROM tbl01_FullCompare " & _
>         "WHERE (((tbl01_FullCompare.ShutType) Like 
>[forms]![frm01_ProcessErr]![cmbShutType]));"
>
>The filtering works properly, and cmb2 displays the filtered dates correctly 
>(based on the selection in cmb1) on the form.
>
>However, but the actual value stored in cmb2 (which should be ImpDate), is 
>actually ShutType - can anyone advise why it displays the correct Date value, 
>but stores another value?  How can I fix this?

Change the Combo's BoundColumn property from 1 (storing the first field in the
query, namely ShutType) to 2 (store the second column, ImpDate).

You can also change the LIKE to = since the LIKE operator is intended for use
with wildcards; you want an exact match, not a partial match.
-- 

             John W. Vinson [MVP]
0
John
2/8/2010 3:26:59 AM
Hi Doug,

Thanks for your reply - I tried your SQL, and it works but the second combo 
box always goes back to the 1st selection.  For example if I choose the third 
date when I select the down arrow, the Combo box displays only the first 
selection.  Its an unbound combo box, what would be causing this?

Cheers,
GLT

"Douglas J. Steele" wrote:

> Your quotes are wrong. What you've got ends up with a SQL string
> 
> SELECT DISTINCT tbl01_FullCompare.ShutType, tbl01_FullCompare.ImpDate FROM 
> tbl01_FullCompare WHERE tbl01_FullCompare.ShutType = " & Me![cmbShutType] & 
> " ORDER BY tbl01_FullCompare.ImpDate;"
> 
> In other words, it's looking for the literal string " & Me![cmbShutType] & 
> ", whereas you want it to be looking for whatever's been selected in the 
> combo box.
> 
> Change your code to
> 
> strSQL = "SELECT DISTINCT ShutType,  " & _
>   "ImpDate FROM tbl01_FullCompare " & _
>   "WHERE ShutType = """ & Me![cmbShutType] & _
>   """ ORDER BY ImpDate;"
> 
> That's three double quotes in a row, as opposed to the two double quotes in 
> a row that you have.
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
> 
> 
> 
> "GLT" <GLT@discussions.microsoft.com> wrote in message 
> news:8A3F546B-9487-482D-B850-0D48632E2E47@microsoft.com...
> > Hi,
> >
> > I have two Combo fields:
> >
> > cmb1 (which has a choice of PROD / DEV)
> > cmb2 - I want to list dates associated either PROD or DEV.
> >
> > I have this SQL for cmb1:
> >
> > strSQL = "SELECT DISTINCT tbl01_FullCompare.ShutType,
> > tbl01_FullCompare.ImpDate FROM tbl01_FullCompare WHERE
> > tbl01_FullCompare.ShutType = "" & Me![cmbShutType] & "" ORDER BY
> > tbl01_FullCompare.ImpDate;"
> >
> > Me![cmbImpDate].RowSource = strSQL
> >
> > However when I i select the cmbImpDate drop down box, there are no records
> > listed... can anyone advise how to get this working?
> >
> > Any assistance is always greatly appreciated...
> >
> > Cheers,
> > GLT. 
> 
> .
> 
0
Utf
2/8/2010 3:57:01 AM
Thanks QB and John for your replies, I fixed the problem.

John and Doug you were both right - I replaced the string and set the bound 
field to 2 and uncommented out some code that I had forgotten about and now 
all is fine.  Thanks so much for your help :).

"GLT" wrote:

> Hi Doug,
> 
> Thanks for your reply - I tried your SQL, and it works but the second combo 
> box always goes back to the 1st selection.  For example if I choose the third 
> date when I select the down arrow, the Combo box displays only the first 
> selection.  Its an unbound combo box, what would be causing this?
> 
> Cheers,
> GLT
> 
> "Douglas J. Steele" wrote:
> 
> > Your quotes are wrong. What you've got ends up with a SQL string
> > 
> > SELECT DISTINCT tbl01_FullCompare.ShutType, tbl01_FullCompare.ImpDate FROM 
> > tbl01_FullCompare WHERE tbl01_FullCompare.ShutType = " & Me![cmbShutType] & 
> > " ORDER BY tbl01_FullCompare.ImpDate;"
> > 
> > In other words, it's looking for the literal string " & Me![cmbShutType] & 
> > ", whereas you want it to be looking for whatever's been selected in the 
> > combo box.
> > 
> > Change your code to
> > 
> > strSQL = "SELECT DISTINCT ShutType,  " & _
> >   "ImpDate FROM tbl01_FullCompare " & _
> >   "WHERE ShutType = """ & Me![cmbShutType] & _
> >   """ ORDER BY ImpDate;"
> > 
> > That's three double quotes in a row, as opposed to the two double quotes in 
> > a row that you have.
> > 
> > -- 
> > Doug Steele, Microsoft Access MVP
> > http://I.Am/DougSteele
> > (no e-mails, please!)
> > 
> > 
> > 
> > "GLT" <GLT@discussions.microsoft.com> wrote in message 
> > news:8A3F546B-9487-482D-B850-0D48632E2E47@microsoft.com...
> > > Hi,
> > >
> > > I have two Combo fields:
> > >
> > > cmb1 (which has a choice of PROD / DEV)
> > > cmb2 - I want to list dates associated either PROD or DEV.
> > >
> > > I have this SQL for cmb1:
> > >
> > > strSQL = "SELECT DISTINCT tbl01_FullCompare.ShutType,
> > > tbl01_FullCompare.ImpDate FROM tbl01_FullCompare WHERE
> > > tbl01_FullCompare.ShutType = "" & Me![cmbShutType] & "" ORDER BY
> > > tbl01_FullCompare.ImpDate;"
> > >
> > > Me![cmbImpDate].RowSource = strSQL
> > >
> > > However when I i select the cmbImpDate drop down box, there are no records
> > > listed... can anyone advise how to get this working?
> > >
> > > Any assistance is always greatly appreciated...
> > >
> > > Cheers,
> > > GLT. 
> > 
> > .
> > 
0
Utf
2/8/2010 4:30:01 AM
Reply:

Similar Artilces:

Filters *SOS* Filters *SOS* Filters *SOS*
1) On formLoad, I need to show only those items which are unassigned. 2) I need for the end-under to select only the items they are assigned to. 3) I need an option to select "ALL" so I can view all items. Any insight offered would be appreciated!!! On Wed, 29 Aug 2007 16:24:01 -0700, valdaiway <valdaiway@discussions.microsoft.com> wrote: >1) On formLoad, I need to show only those items which are unassigned. Use a query to put a criterion on the field that defines the assigned status. I assume you know how that information is stored in your table; nobody here does, ...

Printing Comments #2
Thank you soooooooooooooo much - you can't imagine how frustrating thi was. : -- choskin ----------------------------------------------------------------------- choskins's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1631 View this thread: http://www.excelforum.com/showthread.php?threadid=27709 ...

Criteria for Advanced Filter HELP
I have what I think is a simple question that I need answered IMMEDIATELY. I have a spreadsheet with 20 fields and I want to filter it so it only shows records that have something in of any of 5 of those fields. So once filtered, I will not have any records that have all 5 of those fields blank. I know I have done this before but I'll be damned if I can remember or find out how. -- Thanks You all are teaching me so much don't cross-post -- answer supplied in misc NG "knowshowrosegrows" <knowshowrosegrows@discussions.microsoft.com> wrote in message news:ACBC0...

Employee Filters
Hello: On the employee filters in the HR Preferenes window, would this restrict seeing employee information in both Payroll and HR? Also, would it restrict reporting on certain employees in a division or department? Thanks! childofthe1980s Your message does not indicate which version of Great Plains you are using. Using 8.0 with SP3 applied, HR filters do apply to some of employee information outside of HR. The settings will filter selected forms, Smartlists and Lists items. The HR filter setting do not apply to reports outside of HR. The filtered forms are: Employee Maintenance,...

Filtering based on a filter
Hello, I have an Excel Worksheet with a Pivot Table at the top with a Filter and a data set returned from a DB2 database below it. I would like to filter the DB2 data set based on the Pivot Table filter that is enabled. Any ideas? Thanks! James, You can't filter two ranges on the same worksheet. You can, instead, drill-down on your pivot table, which will show all items that go into the value on a newly created separate sheet. The drawback to that is that you cna only drill down on one item at a time, and it is a separate sheet. HTH, Bernie MS Excel MVP "James" <an...

phatom message in Outlook 2003 #2
for some reason outlook 2003 keeps showing 1 message inbox in the all mail folders section when there isn't one. can I clear this --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 080203-0, 02/03/2008 Tested on: 2/5/2008 10:18:58 AM avast! - copyright (c) 1988-2008 ALWIL Software. http://www.avast.com ...

Question on the IMF filtering in exchange...
Hey I installed the IMF filter last night and it works great, with one exception. I set both thresholds to the same (5) and got almost all blocked emails into the archive that were junk...So that is good. However I had some users report that there was mail in their junk folder that should have been good Inbox mail. This I undersyand and can live with as folas-positives...the problem is, since both settings on the folter tab were set to 5, how does it know to send the mail to archive rather than Junk folder? Why wouldn't it just send them all to archive if both settings were at ...

Print Customer Statement (or similar report) w/o closing billing c #2
Print Customer Statement (or similar report) w/o closing billing cycle Is there a way to print a customer statement or similar report before closing billing cycle? None of the reports available would show/print a statement. Anyideas or suggestions? Thanks In Manager go to journal menu and choose Close Billing cycle. On the screen that pops up select Reprint Customer Statement in the Option box at the top. This will allow you to print a statement by date range without closing the cycle. It will warn you that you are closing the cycle but it really isn't when you just reprint so you c...

Access 2007 Run-time Error 2467 when accessing a listbox value on a sub form
I have a database that has been in production on Access 2003 for quite some time and has run without errors. A user's machine was recently upgraded to Access 2007 and now the database throughs a Run-time Error 2467 "The Expression you entered referes to an object that is closed or does not exist" on the following line that references a listbox value on a sub form. If Nz(Me.sfrm_Consultant_Contract_Request.Form.Cmb_Consultant.Value) = "" Then .. .. .. I changed the code to If Nz(Forms! frm_Main.sfrm_Consultant_Contract_Request.Form.Cmb_Consultant.Value) = ""...

Filtering without Filter
I just don't get the following. Any ideas? "A" row I have two different values I use: "Contact" and "Not a contact". "B" row I have the person's name (employee). "C" row I have a quantity, just one number. Now what I need is to output quantities of how many Contacts Employee1 or Employee2 or Employee3 have. Also what I need is to get the number of contacts - which can be found on row "C". Should I use COUNT.IF ? Row A can have 2 or more different values so should there be somekind of conditional IF function included? T...

Filtering #11
Hi, can ayone tell me how I could do the following in excel 2007 or 2010: Horse Trainer Sam M Jones John M Jones Colin S Attwater Steve J Jackson Brian B Mathers James B Mathers Martin G Raggy Patrick S Thomson What I want to do is filter the dataset on 'Trainer' so that it only shows me the Trainers who feature once in the list. So if I was to do this properly it would only show S Attwater and G Raggy as the other trainers have more than one horse..... Hopefully someone can help because it is driving me crazy !! Thanks David Give this macro a try... Sub HideDuplicateTr...

Xpath problems #2
Hi, I'm trying to display the data from my typed dataset on a page using the Xml web control. I have the following code: Xm1.Document = new XmlDataDocument(ds); Using the debugger, I found that the xml representation of my dataset looks like the following: [code:1:877c35039f] <dsData> <Entry> <Title>Test</Title> <Description>This is a test</Description> </Entry> </dsData> [/code:1:877c35039f] My xsl file looks like this [code:1:877c35039f] <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet...

MS Office #2
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I have Student Teacher version 2008. I have MS Office installed on three different MAC's with three individual codes (Allows for three installs). When MS Office is running on my wife's MAC Book, and I run it my iMAC, I get an error message that I'm exceeding the licenses. I'm not. How do I get this to stop?? ...

Formatting Subtotals #2
When using Data, Subtotals to create subtotals in a detailed spreadsheet, how do I set the format so that all subtotal lines are bolded and are followed by a specified number of blank rows? One option - Collapse the sheet to show only the subtotals, then select visible cells only (F5>Special>Visible Cells only) Then Bold those cells and, instead of adding empty rows, make the subtotal rows taller and format them with the vertical alignment at the top "slh" wrote: > When using Data, Subtotals to create subtotals in a detailed spreadsheet, > how do I set the f...

Problem with links #2
I upgraded to service pack 2 last week. I use Outlook for mail and since the SP2 install, every time I click on a link to a web page in an email it takes me to a folder named "nt". What is happening? And what do I need to do. Thanks. ...

Two CRM Servers (1.2 and 3.0) in the same domain?
Is it possible to install a CRM 3.0 in a domain that it's already been used for CRM 1.2? I want to install in a different server, but using the same domain for authentication. We use the 1.2 for sales and the 3.0 we want to use for development. -- Microsoft Business Solutions Certified Professional–Microsoft CRM Applications Professional Microsoft Business Solutions Certified Professional–Microsoft CRM Customization Yes you should be able to. Just create a new OU in Active Directory to install CRM 3.0 in. It's also in 3.0 it's not tied to any Organization name, so you ca...

Junk filter BEFORE other filters?
I am running Outlook 2003 and the Junk filter was working really well. Then I started making other filters...one of them looks for my domain name in the headers and if it's there it moves the email to a folder. Problem is, this filter seems to activate before the junk filter, so the junk sn't being filtered now! How can I set the junk filter to do it's job first and THEN to run my own rules? -- Bryan Anderson <www.anderson-it.com> I created this rule and set it as the first rule to run: Apply this rule after the message arrives with 'X-Spam-Level:******'or'...

Application does not launch in IE ? #2
Hello people, I have a user that launches IE and goes to the correct URL to sign in into CRM 4.0, just like all my other users do. He uses his correct credentials, tries to logon and then nothing happens. That is, he gets the request to log in again. No error message, nothing. Just the screen to sign in again like he just started. This is not a problem with the user itself, but rather with the PC - other users have the same problem on that PC and the application runs fine on other PC's. I know there is something that *does* work, since when I use the wrong credentials, I get an er...

Macro to copy a VLOOKUP formula
Hello, I was wondering if somebody could help me with this macro… I have some data with a filter on, so that only the rows with blank cells are showing. I want to enter a VLOOKUP in the cell, and copy it down to all the blank cells. I tried just recording a macro, but when I run the macro it doesn’t work. Any ideas of how to do it? Example: 1) Before the filter: Colums A -B - C A x x - 1st Row A - 2nd Row A x x - 3rd Row A - 4th row A x x - 5th row 2) After the fil...

Going from one combo to another
I have a worksheet with some combo boxes. I want to hit the tab key and move from one combo to the next one. Is that possible? How is it done? -- bernardoafs ------------------------------------------------------------------------ bernardoafs's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=28993 View this thread: http://www.excelforum.com/showthread.php?threadid=489382 Hi, if you open goto your userform properties, there is an area called Tab Index. alter the numbers to your tab preference as they are automatically set by the point you added your combo b...

Outlook 2003 Signature #2
I have setup multiple email accounts in Outlook. I have also assigned a signature to a non-default email account. If I set it for reply it works fine. However, I cannot get the signature to add to a new email message. It works for the default account, but not when I change the account to something other than the default. I think this used to work, but not now. Anyone with any ideas please reply by email. Thanks YOu need to turn on WordMail as your email editor. Tools | Options | Mail Format -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for...

Bubbble chart -How to automatically add series names, X, Y values
I have about 200 + entries that needs to be plotted in a Bubble Chart Is there a way to automatically add in series names, X, Y and Bubble Size to plot the bubble chart? Hi, Not automatically. Instead use a helper column to concatenate the required text and then use Rob Bovey's free chart labeler addin to link data labels to cells. http://www.appspro.com/Utilities/ChartLabeler.htm Cheers Andy RHI wrote: > I have about 200 + entries that needs to be plotted in a Bubble Chart > Is there a way to automatically add in series names, X, Y and Bubble Size to > plot the bubble c...

look up #2
I will have column B which I needs to be either a "Yes" or "No" depending of what is entered in column C. There are 36 possibilities for column C. Can someone tell me the easiest way to auto fill "Yes" or "No" in column B? thank you "frank" <mrfrank73@aol.com> wrote in message news:098901c3c96d$14303df0$a501280a@phx.gbl... > I will have column B which I needs to be either a "Yes" > or "No" depending of what is entered in column C. There > are 36 possibilities for column C. Can someone tell me > t...

Pasting into a filtered list
Can anyone tell me if it is possible to paste a list of price updates into a filtered list. - I have filtered the list to show just the products whose prices need to be updated, when I try to paste the updated prices, into the list, the prices are not just pasted into the visible cells but the hidden cells between. Can I paste into the visible cells only or do I have to update each line manually. I am using Excel 2002 Any help would be much appreciated Can you sort the list to bring the products that need updating together in the list? If not, try something like this: Your list of product...

Colors #2
Hello I am aware that the following may not be exactly an Excel question, but none the less I hope someone will explain. Why is it that in Excel's Colors dialog box (Custom) one can mix red, green and blue and not the primary colors red, blue and yellow?. Guess I should know, but I don't. Hans Knudsen I believe the answer is related to the way a monitor produces color on the pixel level. The primary colors for each pixel are Red, Blue, and Green, (known as RBG). Primary colors generally relate to the way offset presses work using the 3 primary colors overlaping each other, plus o...