Hi Naomi,
SELECT - SQL has problem with corectly evaluating THIS and THISFORM.
Yes, you can use varibale, but the variable must be PUBLIC (visible for control on form).
Or another solution...
thisform.cboCategories.rowsource = "select * from csrCategories where department = SPACE(10) or department = '"+This.Value+"' into cursor csrCat"
thisform.cboCategories.Requery()
MartinaJ
>Hi everybody,
>
>This should be very simple, but for some reason doesn't work for me.
>
>I have two combos on the form, one is Departments, another is Categories.
>
>I want Categories to depend on Departments.
>
>So, this is what I tried to set as Categories combo rowsource, but when I try to select records from Categories I got variable cDepartment not found:
>
>with thisform.cboDepartments
> .rowsourcetype = 2
> .rowsource = 'csrDepartments'
> .BoundColumn = 2
> .listindex = 1
>endwith
>with thisform.cboCategories
> .rowsourcetype = 3
> .rowsource = "select * from csrCategories where department = SPACE(10) or department = ?m.cDepartment into cursor csrCat"
> .listindex = 1
> .BoundColumn = 2
>endwith
>
>In department's Interactive Change I set this private variable and requery the combo. Only when I touch categories combo I got an error.
>
>I tried originally using thisform.cSelDepartment instead of department = ?m.cDepartment, but it also didn't work - I was getting an error I can not use a method - something along these lines.
>
>I guess I will have with re-building the combo's source every time, e.g. rowsource = '', select, requery.
>
>What do you think?
>
>Thanks in advance.