Arvin, thanks for taking a look.
I removed the Echo False and it didn't appear to make any difference.
On the form itself, the unassociated labels are sitting in the same
location as the corresponding associated label. The unassociated lable has
visible True, the associated lable has visible False.
Here's the code:
Option Compare Database
Option Explicit
Private Const Rev As String = "(12412)" 'mmddhh of last revision
' Revision History
' 1/24/09 Revise "Show All" behavior
' 12/24/08 Revise Sort Orders
' 11/07/08 Add test for empty recordset to ApplyFilter
' 09/29/08 Change test date sort order
' 08/29/08 Add Include Scheduled Filter
' 08/15/08 Finish initial testing
Dim sqlTestDate As String 'Filter Criteria for TestDate
Dim sqlSampleDate As String 'Filter Criteria for SampleDate
Dim sqlLocation As String 'Filter Criteria for Location
Dim sqlSchedule As String 'Filter Criteria for ShowSchedule
Dim sFilter As String 'Assembled Filter Criteria
Dim sOrder As String 'Order By Crititeria
Dim bTestDate As Boolean 'Sort All by Test Date
Private Sub cboLocation_AfterUpdate()
ApplyFilter
End Sub
Private Sub cboSampleDate_AfterUpdate()
Me.cboTestDate = Null
ApplyFilter
End Sub
Private Sub cboTestDate_AfterUpdate()
Me.cboSampleDate = Null
ApplyFilter
End Sub
Private Sub cmdReturn_Click()
DoCmd.Close , , acSaveNo
If FormLoaded("Hidden Form") Then
DoCmd.Close acForm, "Hidden Form", acSaveNo
Application.Quit
End If
End Sub
Private Sub cmdShowAll_Click()
Me.cboLocation.Value = Null
Me.cboSampleDate = Null
Me.cboTestDate = Null
bTestDate = False
ApplyFilter
End Sub
Private Sub cmdShowScheduled_Click()
' Toggle state of ShowScheduled satus
With Me.cmdShowScheduled
If .Tag = True Then
.Tag = False
.Caption = "Includ&E Scheduled"
.ForeColor = cmDkRed 'Dk Red
sqlSchedule = "[PSI] Is Not Null"
Else
.Tag = True
.Caption = "Remov&E Scheduled"
.ForeColor = cmTeal 'Teal
sqlSchedule = ""
End If
End With
ApplyFilter
End Sub
Private Sub Form_Load()
Me.Caption = "MCSS Cylinder Data " & Rev
Me.cboTestDate = Date - 14
Me.InsideHeight = 7635 'twips
Me.cmdShowScheduled.Tag = True
cmdShowScheduled_Click 'Toggle status and apply filter
End Sub
Private Sub ApplyFilter()
' Test Date and Location may be combined,
' sort on Test Date, Location, Pour Height.
' Location and Sample Date may be combined,
' sort on Location, Sample Date, Pour Height, Age.
' Show All sort on Location, Sample Date, Pour Height, Age.
' After Update code for either date sets the other
' date to Null.
' Show Scheduled is always combined with other filters,
' and is set by OnClick event.
' 1/24/09 Show All Click now resets both date filters.
' 12/24/08 revise Sort Order
' Sample was: Location, Sample Date, Test Date.
' Test was: Test Date, Location.
' Get Combo Box Values
sqlLocation = ""
If Not IsNull(Me.cboLocation.Value) Then
sqlLocation = BuildCriteria("[Location]", dbText, _
Replace(Me.cboLocation.Value, ",", "?"))
End If
sqlSampleDate = ""
If Not IsNull(Me.cboSampleDate.Value) Then
sqlSampleDate = BuildCriteria("[Sample Date]", dbDate, _
">=" & Me.cboSampleDate.Value)
End If
sqlTestDate = ""
If Not IsNull(Me.cboTestDate.Value) Then
sqlTestDate = BuildCriteria("[Test Date]", dbDate, _
">=" & Me.cboTestDate.Value)
End If
' Set Default Criteria
sFilter = ""
sOrder = "[Location],[Sample Date],[Pour Height],[Age]"
If sqlSampleDate <> "" Then
sFilter = "(" & sqlSampleDate & ")"
sOrder = "[Location],[Sample Date],[Pour Height],[Age]"
End If
If sqlTestDate <> "" Then
sFilter = "(" & sqlTestDate & ")"
sOrder = "[Test Date],[Location],[Pour Height]"
End If
If bTestDate Then
sOrder = "[Test Date],[Location],[Pour Height]"
End If
If sqlLocation <> "" Then
If sFilter <> "" Then
sFilter = sFilter & " AND (" & sqlLocation & ")"
Else
sFilter = "(" & sqlLocation & ")"
End If
End If
If sqlSchedule <> "" Then
If sFilter <> "" Then
sFilter = sFilter & " AND (" & sqlSchedule & ")"
Else
sFilter = "(" & sqlSchedule & ")"
End If
End If
' Debug.Print sFilter
' Debug.Print sOrder
DoCmd.Hourglass True
'dp "Hourglass True"
Me.Repaint
Application.Echo False
With Me.MCSS_Recent_Breaks.Form
If sFilter <> "" Then
.Filter = sFilter
.FilterOn = True
Else
.FilterOn = False
End If
.OrderBy = sOrder
.OrderByOn = True
If .Recordset.RecordCount > 0 Then
.Recordset.MoveLast
Me.MCSS_Recent_Breaks.SetFocus
.Test_Date.SetFocus
End If
End With
Application.Echo True
Me.Repaint
DoCmd.Hourglass False
End Sub
Private Sub Location_Label_Click()
Me.cboLocation.Value = Null
ApplyFilter
End Sub
Private Sub Sample_Date_Label_Click()
Me.cboTestDate.Value = Null
Me.cboSampleDate.Value = Null
bTestDate = False
ApplyFilter
End Sub
Private Sub Test_Date_Label_Click()
Me.cboSampleDate.Value = Null
Me.cboTestDate.Value = Null
bTestDate = True
ApplyFilter
End Sub
Arvin Meyer said:
I couldn't duplicate your hourglass problem, so either Echo False is
causing the problem, or you are trying to run code on an associated
(sticky) label, which doesn't have events. Can you post the more of the
code?
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com