Cascade or Dependent Combo Box Woes

Christine Pearc

Christine
Local time
Today, 03:02
Joined
May 13, 2004
Messages
111
Hi, Gang.

For my life, I can’t get my dependent combo boxes to work, despite looking at downloaded samples and reading every thread here and elsewhere. Could someone take a look and tell me what’s wrong:

What needs to happen is this: When the user selects a CauseCategory in one combo box, only the CauseCodes associated with the Cause Category appear in the CauseCode field. Note that I want both the CauseCategoryID and CauseCodeID to be stored in the table, so this is why I’ve used bound controls for each field.

TBLCAUSECATEGORIES
Fields: CauseCategoryID (AutoNumber) and CauseCatDesc (Text)

TBLCAUSES
Fields: CauseCode (AutoNumber), CauseDesc )(Text), CauseCategoryID (Number)

There is a relationship between CauseCategoryID in both tables.

On the data entry form, there are the following fields:

CauseCategoryID. This combo box gets its info from a query, shown below. Column count = 2; Bound Column = 1 (the AutoNum ID)

SELECT tblCauseCategories.CauseCategoryID, tblCauseCategories.CauseCatDesc FROM tblCauseCategories;

The After Update procedure for CauseCategoryID is:
Private Sub CauseCategoryID_AfterUpdate()

On Error Resume Next
CauseCodeID.RowSource = "SELECT tblCauseCodes.CauseCodeID " & _
"FROM tblCauseCodes " & _
"WHERE tblCauseCodes.CauseCategoryID = '" & CauseCategoryID.Value & "' " & _
"ORDER BY tblCauseCodes.CauseCodeID;"

End Sub

Nothing happens, or sometimes after playing around with the code a bit I get “Data Type Mismatch in Criteria Expression”

This should be SOOOO simple. What’s wrong?
Ta,
Christine
 
If anyone was going to heed my plea for help... nevermind! I just found another post from someone who was having similar problems to me with code we had both been using as an example at http://www.fontstuff.com/access/acctut10.htm.

Rich (Leo "The One") provided a sample CascCom demo (5-16-2004), which seems to have fixed the problem. Haven't tested yet, but hopefully this Rich's example has set me on the right path.
 

Users who are viewing this thread

Back
Top Bottom