Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

message for fancyprairie

Status
Not open for further replies.

daveonion

Programmer
Aug 21, 2002
359
GB
alright Fancyprairie
thanks for your advice, the only other thing is where about do you insert the code, i'm confused on the where abouts of where you place it, do you insert it directly in the row source of the second combo or somewhere else?
thanks once again
 
I put the code in the OnChange event of the first combobox (in my case, cboFacility). So when the user selects a different Facility from the combobox (OnChange), the second combobox is filtered based on the Facility (see previous response to your post).

By the way, the ListRowSource of the second combobox (cboDept) initially contains all departments regardless of Facility. And the cboDept is initially disabled (Disable property set to False).

I declared a global variable (gintFacilityID) that keeps track of the last Facility the user selected so I know whether I need to issue the ServerFilter command or not.

When the user selects a new Facility do the following:

Code:
If (len(cboFacility.value)=0) then  'IF True, nothing selected
    cboDept.disabled = true
    cboDept.value = 0
else
    cboDept.disabled = false
    if (gintFacilityID <> cboFacility.value) and (cboFacility.value <> 0) then
        MSODSC.RecordsetDefs.item(&quot;qryDept&quot;).ServerFilter =  &quot;intFacilityID = &quot; & cboFacility.value
    end if

cboDept.value = &quot;You should put something here because cboDept.value is cleared if the dropdown box does not contain the item cboDept.value represents&quot;
		
end if

gintFacilityID = cboFacility.value

Keep me posted on whether or not this works. I'll be checking periodically for your reponse.
 
daveonion (Programmer) Sep 6, 2002
Alright Fancyprairie, once again thanks for your help,
the code i am using is below (same as the code you supplied), however an error message is returned when i select a region from the region combo as follows
&quot;data provider failed while executing a command&quot;, i then click ok and the following appears
&quot;Syntax error (missing operator)in query expression '(regions = region 3)'.

Region 3 is the region I selected from the first combo box, so what ever region I select it returns the same error only with the selected region i.e. region 1, region 2, region 3 etc.


Enterregioncom = first combo box
departmentqu = rowsource for second combo box
enterdeptcom = second combo box
regions = field in departmentqu



Code
if (len(enterregioncom.value)=0) then 'if true,nothing selected
enterdeptcom.disabled = true
enterdeptcom.value = 0
else
enterdeptcom.disabled = false
msodsc.RecordsetDefs.Item(&quot;departmentqu&quot;).ServerFilter = &quot;regions = &quot; &
enterregioncom.value
end if



any ideas where i am going wrong, i know i haven't declared a global variable as of yet, but i thought that it would work without it, am i using the wrong syntax or code somewhere, once again any help would be largely appreciated
Dave
 
Is &quot;regions&quot; defined as text or number in your table? I'm assuming it's a number. Try hardcoding the ServerFilter command to see if you can get it to work. For example,
msodsc.RecordsetDefs.Item(&quot;departmentqu&quot;).ServerFilter = &quot;regions = 3&quot;

If that doesn't work try this:
msodsc.RecordsetDefs.Item(&quot;departmentqu&quot;).ServerFilter = &quot;regions = '3'&quot;

I'm just guessing now. I just verified the syntax with the one I've got working and it looks ok.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top