Re: combo question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ken Snell [MVP] (kthsneisllis9_at_ncoomcastt.renaetl)
Date: 03/18/05


Date: Fri, 18 Mar 2005 14:43:14 -0500

You use SCHOOLS as the table name in the rest of the SQL statement, but you
used School (no s) in the WHERE clause.

-- 
        Ken Snell
<MS ACCESS MVP>
"rob" <rob@discussions.microsoft.com> wrote in message 
news:C19A7C42-5F8E-4929-BE73-A70DA2A78D3F@microsoft.com...
> Hi.I've just added the WHERE clause to my rowsource as follows:
>
> Row source for combo 2 = Select distinct [SCHOOLS].[nschid],
>> > > [SCHOOLS].[SCHOOL], [SCHOOLS].[PRINCIPAL], [SCHOOLS].[EMAIL],
>> > > [SCHOOLS].[PHONE], [SCHOOLS].[FAX] FROM SCHOOLS WHERE 
>> > > ((([School.nschid])=[me]![cmb_district].[district_id]));
>
> I also added an afterupdate event to the first combo box to requery the
> second combo box. It still doesn't seem to work.
>
> "Ken Snell [MVP]" wrote:
>
>> As I noted in an earlier reply to your post (
>> news:Oknt5lYKFHA.3356@TK2MSFTNGP12.phx.gbl ), this article tells you how 
>> to
>> tie the two combo boxes together:
>> http://www.mvps.org/access/forms/frm0028.htm
>>
>> The "trick" is that you must have a WHERE clause in the Row Source SQL
>> statement for the second combo box, where that WHERE clause uses the 
>> value
>> of the first combo box as the "criterion" value. And that you use the
>> AfterUpdate event of the first combo box to requery the second combo box.
>>
>> The row source you're using has no filtering criterion, so of course it 
>> will
>> show all records.
>>
>> And this article tells you how to show the other columns of a combo box 
>> in
>> textboxes:
>> http://www.mvps.org/access/forms/frm0058.htm
>>
>> You use the AfterUpdate event of the combo box to write the values from 
>> the
>> other columns into the textboxes, not the BeforeUpdate event.
>>
>> Your code for the BeforeUpdate event that is validating the entries is 
>> fine
>> for the first two tests, except that your code doesn't cancel the
>> BeforeUpdate event when the validation test fails.
>>
>> If cmb_SCHOOL = "*" Then
>>     MsgBox "Select a postal code.", vbExclamation, "Postal Code"
>>     Cancel = True
>> ElseIf cmb_postcode = "" Then
>>     MsgBox "Select a postal code.", vbExclamation, "Postal Code"
>>     Cancel = True
>> End If
>>
>>
>> -- 
>>
>>         Ken Snell
>> <MS ACCESS MVP>
>>
>> "rob" <rob@discussions.microsoft.com> wrote in message
>> news:E3499837-250E-4AF4-8FE7-7C9C3A78A775@microsoft.com...
>> >I have 2 combo boxes and 5 text boxes. I want the second combo box only 
>> >to
>> > display the items that are linked to my selection in combo box 1. Then
>> > when I
>> > select the appropriate text from combo 2, I want the 5 text boxes to
>> > display
>> > the text that is linked to my cvombo 2 choice in my 5 text boxes. here 
>> > is
>> > my
>> > code so far which does step 2 by populating the 5 text boxes when i 
>> > make a
>> > selection in combo 2. My problem being i can't get combo 2 results to 
>> > only
>> > reflect my choice from combo 1. all choices are still displayed in 
>> > combo 2
>> > for all criteria. Here is my code so far.
>> >
>> > Row source for combo 2 = Select distinct [SCHOOLS].[nschid],
>> > [SCHOOLS].[SCHOOL], [SCHOOLS].[PRINCIPAL], [SCHOOLS].[EMAIL],
>> > [SCHOOLS].[PHONE], [SCHOOLS].[FAX] FROM SCHOOLS;
>> >
>> > Column count =6
>> > Column widths = 0.5299";0.35";0.2799";0.1;0.1;0.1"
>> >
>> >
>> > Private Sub cmb_school_BeforeUpdate(Cancel As Integer)
>> >
>> > If cmb_SCHOOL = "*" Then
>> >    MsgBox "Select a postal code.", vbExclamation, "Postal Code"
>> > ElseIf cmb_postcode = "" Then
>> >    MsgBox "Select a postal code.", vbExclamation, "Postal Code"
>> > Else
>> >    txt_nschid = Forms![School]![cmb_school].Column(0)
>> >    txt_SCHOOL = Forms![School]![cmb_school].Column(1)
>> >    txt_PRINCIPAL = Forms![School]![cmb_school].Column(2)
>> >    txt_EMAIL = Forms![School]![cmb_school].Column(3)
>> >    txt_PHONE = Forms![School]![cmb_school].Column(4)
>> >    txt_FAX = Forms![School]![cmb_school].Column(5)
>> >
>> > End If
>> >
>> > End Sub
>> >
>> > Do i have to use SQL in my first combo box since I can't use the 
>> > rowsource
>> > in combo 2. Any help would be appreciated.
>>
>>
>> 


Relevant Pages

  • Re: recent drivel posted by Tony Rogerson on his blog
    ... Like I said, I want to search on terminology not on syntax - for instance, we call using the WITH syntax a 'common table expression' I've no idea what the equiv is in Oracle. ... the common SQL Standard term "derived table" ... Actually I tried and it returned 2,614,868 results back and not a useful link in sight for someone looking for the WITH SQL statement I was after? ... You guessed it, 42,185 links showing links on things to do with 'clause' ... ...
    (comp.databases.oracle.server)
  • Re: SQL parameter query not returning values
    ... from 11/14 - 11/27 as test records. ... ' Define the parameters clause. ... ' Define an SQL statement with the parameters ...
    (comp.databases.ms-access)
  • Re: Error: Specified field could refer to more than one table
    ... The error message is "The specified field "[2005 Max ... FROM clause of your SQL statement. ... If you can't figure it out, you might post the SQL text of your query. ...
    (microsoft.public.access.queries)
  • Re: Left Join Not Supported - translated from legal SQL statement
    ... It IS a join and is a perfectly legal SQL statement, ... and SQL) then it would show that having this in the where clause ... excludes the data I need in the left join too early in the execution ...
    (comp.databases.ms-access)
  • Re: Better "Join" vs "Where" clause?
    ... running the SQL directly, in the SQL Server tools, rather than ... WHERE clause has been deprecated, ... AFAIK one cannot perform an outer join in Access without using the explicit ...
    (microsoft.public.access.queries)