Cant figure this out !

D

Dave Elliott

I have a form named Time_Hours with a combo on it that looks up the employee
In the criteria of the control (status) in the query it has this code
[Forms]![frmAutoPayrollReport]![Status]
This means that the combo list for the employee will only show active or
archived employees depending on the status selected via the criteria used
via the main form, I need for it to show all records
Normally the whole form of which Time_Hours is a sub-form on shows only the
records with an active status
However if the main form is opened with a status of archived then the
sub-form still shows only archived employees
and vise versa for the status of active
If the main form is opened with a status of archived, then I need the
employee list on the sub-form Time_Hours to show ALL the records for the
sub-form, active and archived
The Main form has 2 option buttons on it which are used to to set the status
of the whole record.
Here is what I think I need;

If Forms!TimeCards!Status =1 Then ' this means status is archived
Forms!Time_Hours!EmployeeID!Status = 1,2 'either active or archived
End If
 
G

German Saer

Dave,

This is not clear. You're mentioning show but at the end where you say what
you think you need, it seems that you're assigning a value to the property
instead conditioning it. Please re-estructure it and I'll be happy to help
you
 
D

Dave Elliott

Ok, will try to simplify. the below code is in my query so that the form
opens with a status of either active or archived records.
The form also shows a list of employees and there status is either active or
archived.
I need to be able to show ALL records when the status is archived instead of
either active or archived as my choices.
The below code is in the query for the forms employees list and so shows
only active or archived records.
If the form is opened with a status of archived, then I need to see ALL
records.
I need to either change record source upon archive status or modify the
below code to check if the form's status is archived.



[Forms]![frmAutoPayrollReport]![Status] ' either active or archived is the
choice here
 
G

German Saer

Dave,

If you need to modify the record source of a subform query when status
changes, then on the status AfterUpdate event you need to redefine the query
for the subform. By clicking on the status events tab and creating the code
for the redefinition, the code would be something like this:

Procedure Status_AfterUpdate()
SubForm.Form.RecordSource = "SELECT ... FROM ... WHERE Status = " &
Status
End Procedure

Remember to change the name "SubForm" for your actual subform name.
Additionally, if you need to have an initial recordset on the load event of
the main form you can do:

Procedure Form_Load()
Status__AfterUpdate
End Procedure

Hope this helps!
 
Top