Re: combo question
From: Ken Snell [MVP] (kthsneisllis9_at_ncoomcastt.renaetl)
Date: 03/18/05
- Next message: jh: "Compile error:Method or data member not found"
- Previous message: Rick B: "Re: Age Calculations"
- In reply to: rob: "Re: combo question"
- Next in thread: rob: "Re: combo question"
- Reply: rob: "Re: combo question"
- Messages sorted by: [ date ] [ thread ]
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.
>>
>>
>>
- Next message: jh: "Compile error:Method or data member not found"
- Previous message: Rick B: "Re: Age Calculations"
- In reply to: rob: "Re: combo question"
- Next in thread: rob: "Re: combo question"
- Reply: rob: "Re: combo question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|