| |
zeg37
Posts: 15
Score: 0
Joined: 6/16/2006
Status: offline
|
Hi, I am working with a Microsoft Data Page where the records are filtered by two dates the user selects prior to any records being loaded. After selecting dates they click on a button (BtnGo) to fire the filter event. Currently if no records are found that match the criteria, the page just remains empty. I would like the user to receive a message if no records are found for the dates provided. I've spent a lot of time attempting to add a clause to my IF…Then statement but finally figured out that logically it wouldn’t work. What I’m attempting to do now is use “AttachEvent” with my “onclick” event to send a message if a sum field is empty after the records are filtered (which would be the case if no records were found). I’ve cobbled together code for an AttachEvent based on what I’ve found on the internet; although without any clear directions, I’m not sure if I’ve even remotely written it correctly. As currently written, I receive an error message when I open the page that an object is required. I’ve tried both “BtnGo” and “onclick” as my object and received the same error message for both. I would certainly appreciate any suggestions for correcting my code or a head’s up if "AttachEvent" won’t work. Thanks! Zeg <SCRIPT language=vbscript> Sub OnFilterComboChange() Dim stWhere 'Don't do anything unless user selects a value from each list box. If (FromMondayDate.value <> "" and ToSundayDate.value <> "") Then stWhere = "CrewTime.CrewDate>=" & "#" & FromMondayDate.value & "#" & " " stWhere = stWhere & "AND CrewTime.CrewDate<=" & "#" & ToSundayDate.value & "#" stWhere = stWhere & "AND CrewTime.DataCollectorHours<>" & " 0.0" 'Set the server filter on the CrewTime Recordset. MSODSC.RecordsetDefs.Item("CrewTime Other Hours Query").ServerFilter = stWhere End If End Sub </SCRIPT> <SCRIPT language=vbscript event=onclick for=Btngo> <!-- OnFilterComboChange() --> </SCRIPT> <SCRIPT language=vbscript> <!-- dim Check set Check = getRef("CheckTotal") Btngo.attachCheckTotal Check sub CheckTotal() if OtherHours0.value = "" Then msgbox "No records for dates provided." End if End sub --> </SCRIPT>
|
|