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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering the Subform with a toggle button 1

Status
Not open for further replies.

ImStuk

Technical User
Feb 20, 2003
62
US
I have a form that has a subform in datasheet view. There are times on each record in the subform. I would like to have a toggle button on the main form, or something better if suggested, that would filter the subform by am or pm.

Basically it is mail runs, and I would like to be able to quickly view either the am mail run, or the pm mail run with a quick switch. Any suggestions would be greatly appreciated.
 
CREATE A QUERY TO LOOK FOR EITHER AN AM TIME OR PM TIME DEPENDING ON THE VALUEOF THE TOGGLE. PUT THIS IN THE SUBFORMS RECORD SOURCE AND REQUERY IT EACH TIME THE THE TOGGLE BUTTON IS CLICKED.

ANOTHER WAY IS TO CREATE TWO QUERIES ONE FOR AM AND ONE FOR PM AND CALL THE APPROPRIATE QUERY DEPENDING ON THE VAULE OF THE TOGGLE BUTTON.

dAM i JUST TYPED ALL THAT IN WITH THE CAPS ON.


Program Error
Programmers do it one finger at a time!
 
Hi
Or you could try an Option Group:
Code:
Private Sub Frame1_Click()
Select Case Me.Frame1
Case 1 'AM
    Me.MySubform_subform.Form.Filter = "MailRun <= #12:00#"
    Me.MySubform_subform.Form.FilterOn = True

Case 2 'PM
    Me.MySubform_subform.Form.Filter = "MailRun > #12:00#"
    Me.MySubform_subform.Form.FilterOn = True

Case 3 'All
    Me.MySubform_subform.Form.FilterOn = False
End Select
End Sub
 
Remou, I definitely like this method and have gotten this far, but am getting an error. My subform is frm_Routes_Sub.
The time control source is StopTime, but the control name is Stop_Time. Here is what I have so far:

Private Sub Frame7_Click()
Select Case Me.Frame7
Case 1
Me.frm_Routes_Sub.Form.Filter = "Stop_Time < = #12:00PM#"
Me.frm_Routes_Sub.Form.FilterOn = True
Case 2
Me.frm_Routes_Sub.Form.Filter = "Stop_Time > = #11:59AM#"
Me.frm_Routes_Sub.Form.FilterOn = True
Case 3
Me.frm_Routes_Sub.Form.FilterOn = False
End Select
End Sub

The error I am getting is the Can't assign a value etc...
 
Hi
frm_Routes_Sub needs to be the subform name that pops up as an option when typing Me. (me dot), also you need to use the name of the field in the control source, that is, StopTime. Hope I have that right :)
 
Now I am using the following and I am not getting any errors, however, the filter is not working right. Does it need to be a "Between" or am I doing the time wrong? I am close...

Private Sub Frame7_Click()
Select Case Me.Frame7
Case 1
Me.frm_Routes_Sub.Form.Filter = "[frm_Routes_Sub].Form.[StopTime]>#11:59AM#"
Me.frm_Routes_Sub.Form.FilterOn = True
Case 2
Me.frm_Routes_Sub.Form.Filter = "[frm_Routes_Sub].Form.[StopTime]<#12:00PM#"
Me.frm_Routes_Sub.Form.FilterOn = True
Case 3
Me.frm_Routes_Sub.Form.FilterOn = False
End Select
End Sub
 
Hi
I think you need to change this:
[tt]"[frm_Routes_Sub].Form.[StopTime]>#11:59AM#"[/tt]
To:
[tt]"[StopTime]>#11:59AM#"[/tt]

I am not sure about the AM PM time formats. I will play with them for a few minutes. Even though your times are formatted for AM PM, you can still use a twenty-four hour clock (as in my example), because times are only formatted as AM or PM, not stored that way.
 
How are ya ImStuk . . . . .

[tt][blue] #11:59AM#[/blue][/tt] should be:
[tt][blue] #11:59 AM#[/blue][/tt]


Calvin.gif
See Ya! . . . . . .
 
I'm still struggling with this.
1. AM (Case 1) Eliminates every record am and pm.

2. PM (Case 2) Doesn't eliminate anything, jusst seems to requery or something, but stays the same.

3. All (Case 3) Brings everything back.

Here is what I am working with right now:

Private Sub Frame7_Click()
Select Case Me.Frame7
Case 1 'AM
Me.frm_Routes_Sub.Form.Filter = "[frm_Routes_Sub].Form.[Stop Time]>#12:00#"
Me.frm_Routes_Sub.Form.FilterOn = True

Case 2 'PM
Me.frm_Routes_Sub.Form.Filter = "[frm_Routes_Sub].Form.[Stop Time]<#12:00#"
Me.frm_Routes_Sub.Form.FilterOn = True

Case 3 'ALL
Me.frm_Routes_Sub.Form.FilterOn = False
End Select
End Sub
 
Hi
I think it you must change:
[tt]Me.frm_Routes_Sub.Form.Filter = "[frm_Routes_Sub].Form.[Stop Time]>#12:00#"[/tt]
To:
[tt]Me.frm_Routes_Sub.Form.Filter = "[Stop Time]>#12:00#"[/tt]
That is, leave out the refrence to the form name in the filter. I have tried the line the way you have it, and it does not work for me. Also, set AM control to <#12:00# and PM control to >=#12:00#. The PM control will then show both noon and midnight.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top