Turning filter off

Sprocket

Registered User.
Local time
Today, 17:10
Joined
Mar 15, 2002
Messages
70
Hi,

I have a multi-user database sat on a shared drive. It has upto 10 concurrent users.

I've got two forms REGISTRATION and SPECIAL_NEEDS

both forms use the same underlying query for their data

The Registration form always opens in add mode expecting you to enter a new student. It also has a combo box on it that will allow you to call up any previously entered student.

This form records basic information only.

Student_number (primary key), Name, DOB, Course, Address, telephone number, reason for appointment, and Archive

The archive field is a yes/no check box

If a student has had no contact for 12 months
then archive = true

Form 2 -- SPECIAL_NEEDS is much larger (6 tabbed pages) but also shows through the data entered on form 1

Usually form 2 opens without any filter. the client is selected from a combo box and all works well.

The combo box on form 2 is populated from a sub query that only shows current students .ie.. archived = false
This keeps the number of current/active records to a minimum and speeds up the whole process.

However. if the student looked up is not in the list then it automatically opens the REGISTRATION where you can look up from the full list and uncheck the archived box or enter a new record.

What I am trying to do and am having difficulty with is in returning to form 2 and having it open with the currently selected record from form 1

NO that is not quite true --- I can open form 2 with the current record but then the form is locked with that record... the filter button on the toolbar is highlighted and you cannot now select another record from the combo box on form 2.

If you click the filter button ei. turn the filter off then you can select from the combo box.

What I want to do is edit the current record and then turn the filter off with code rather than manually.

I assumed that the "on focus" event of the combo box was the logical place to put some code but I this is where I come unstuck.

I've tried everthing I can think of. I am sure I'm nearly there but getting something wrong. I tried using the DoCmd.ShowAllRrecords action which does free up the main form but blanks out all values from the combo box at the same time.

How can I turn of the form filter with code and in which event do I put it?

Hope this all makes sense to you

Thanks Sprocket
 
private sub form_onload()
Me.FilterOn = false
end sub



does that work?
 
Sadly no, I'm afraid not - it is too early in the cycle because the code that moves from form 1 to form 2 in effects sets the filter to the record I want it to open on therefore form 2 opens on the last visited record rather than the record that is currently selected on form 1

I think it needs to be in the combo on focus or before update event but refering to the form filter rather than the combo filter property.
 
Hi folks - thanks for pointing me in the right direction.

I have now found a solution - for anyone interested it is as follows:

Place the following code in the "On Enter" event of the combo box

[Forms]![Special_needs].FilterOn = False
[Forms]![Special_needs].Form.Refresh
 

Users who are viewing this thread

Back
Top Bottom