Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Code for msgbox when no records found

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,51725
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Code for msgbox when no records found
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Code for msgbox when no records found - 9/10/2007 7:02:42 AM   
  zeg37

 

Posts: 15
Score: 0
Joined: 6/16/2006
Status: offline
I have a data access page which searches for records based on possible 2-3 criteria.  My select case code works successfully for finding records but I would like to add an msgbox that will let the user know when no matching records exist.  I found code that works perfectly on a straightforward page (one with no record grouping) but this particular page groups the records based on a couple of different fields and I think that is what is bombing the msgbox code. I've tried  many variations on the code (highlighted as "trials" with results in red).  I'd certainly appreciate any suggestions.  Below is my code for the page including my trial code:

 
<SCRIPT language=vbscript>
<!--
Dim fInited
fInited=FALSE
 
Sub OnFilterComboChange()
Dim stWhere
 
            'Value of 0 (Zero) is reserved as NO entry for that value
           
            ProjectNumber = 0
            ProjectNumber = 0
            [GroupOfJobType:JobType] = 0
           
            'Value of 1 is reserved for entry's made for the value
           
            IF FromProject.value <> "" THEN ProjectNumber = 1
            IF ToProject.value <> "" THEN ProjectNumber = 1
            IF vJobType.value <> "" THEN [GroupOfJobType:JobType] = 1
           
            SearchValue = ProjectNumber & "," & ProjectNumber & "," & [GroupOfJobType:JobType]
                       
                       
            SELECT CASE SearchValue
           
            CASE "0,0,0"
                        stWhere = "CrewTime.ProjectNumber >='" & FromProject.value & "'"
                        stWhere = stWhere & "AND CrewTime.ProjectNumber <='" & ToProject.value & "'"
                        stWhere = StWhere & "AND Project.JobType Like'" & "%" & vJobType.value & "%" & "'"
            CASE "1,1,0"
                        stWhere = "CrewTime.ProjectNumber >='" & FromProject.value & "'"
                        stWhere = stWhere & "AND CrewTime.ProjectNumber <='" & ToProject.value & "'"
                        'stWhere = StWhere & "AND Project.JobType Like'" & "%" & vJobType.value & "%" & "'"
            CASE "1,1,1"
                        stWhere = "CrewTime.ProjectNumber >='" & FromProject.value & "'"
                        stWhere = stWhere & "AND CrewTime.ProjectNumber <='" & ToProject.value & "'"
                        stWhere = StWhere & "AND Project.JobType Like'" & "%" & vJobType.value & "%" & "'"
            CASE "0,0,1"
                        'stWhere = "CrewTime.ProjectNumber >='" & FromProject.value & "'"
                        'stWhere = stWhere & "AND CrewTime.ProjectNumber <='" & ToProject.value & "'"
                        stWhere = StWhere & "Project.JobType Like'" & "%" & vJobType.value & "%" & "'"
            END SELECT
           
(Trial 1 - Msgbox appears regardless of whether or not records are found.  If records are available, the search does not take place until the msgbox’s “OK” button is pressed)
            'If (MSODSC.GroupLevels(0).DataPageSize < 1) Then
                        'msgbox "No Records Found"
            'End If
           
            MSODSC.RecordsetDefs.Item("CrewTime by Project").ServerFilter = stWhere       
 
(Trial 2 - Code that works on another page but results in just a blank page here)
         If msodsc.DataPages(0).Recordset.RecordCount =0 then
             msgbox "No Records Found"
         End if

(Trial 3 - Msgbox appears regardless of whether or not records are found.  If records are available, they appear concurrently with the msgbox.)
            'If (MSODSC.GroupLevels(0).DataPageSize < 1) Then
                        'msgbox "No Records Found"
            'End If  
                       
End Sub
-->
</SCRIPT>
 
<SCRIPT language=vbscript event=datapagecomplete(oEventInfo) for=MSODSC>
<!--
(Trial 4 - Msgbox appears prior to search taking place but is accurate about reappearing only if records are not found.  I’ve tried other events [ie. Ondatasetchange, ondatasetcomplete, dataerror, onerror] rather than datapagecomplete without success)
            'If oEventInfo.DataPage.Recordset.RecordCount = 0 then
                        'msgbox "No Records Found"
            'end if
-->
</SCRIPT>
 
<SCRIPT language=vbscript event=onclick for=BtnGo>
<!--
            OnFilterComboChange()
-->
</SCRIPT>
 
Thank you in advance for any comments or suggestions!
Zeg
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Code for msgbox when no records found Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts