Question : How to avoid error message when no record can be returned.

I'm receiving monthly reports from space stations. The code below lists the stations that did not submit monthly reports. For those months when all stations submit their reports, I get an error message:
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'left'
How could I replace this error message with something like: "All stations submitted their reports this month."
Thank you for your help
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("MonthlyReports.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select Station from Stations where Station not in (SELECT Station FROM ReportTable WHERE YearOfReport LIKE '%" & Request.Form("MyYearOfReport") & "%' AND MonthOfReport LIKE '%" & Request.Form("MyMonthOfReport") & "%') order by Station", conn

Dim Msg

do until rs.EOF
    Msg = Msg & rs("Station") & ", "
    rs.MoveNext
loop
'remove the last comma
Msg = left(Msg, len(Msg) - 2)
%>
<center>

The following Stations have not submitted their reports in <% = Request.Form("MyMonthOfReport") %>, <% = Request.Form("MyYearOfReport") %>:<br />

<%
response.write  Msg
%>
</center>

Answer : How to avoid error message when no record can be returned.

Beginning at line 14, you could try something like:

'remove the last comma
if LEN(msg) > 0 THEN
Msg = left(Msg, len(Msg) - 2)
end if
Random Solutions  
 
programming4us programming4us