Sub AutoGenerateJobNo()
dim conn
dim rs
dim sqlTmp
Dim FirstID
Dim LastID
Set Conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
sqlTmp = "SELECT TOP 1 RepairID FROM RepairAsset "
sqlTmp &= " ORDER BY RepairID DESC"
rs.open sqlTmp,conn,1
if not rs.eof and not rs.bof then
firstID = cint(left(rs("RepairID"),4))
firstID= right("0000" & firstid,4)
lastID = cint(left(rs("RepairID"),5))+1
lastID= right("00000" & lastid,5)
'****** what is lblJobNo.Text
lblJobNo.Text = firstId & lastid
else
lblJobNo.Text = year(now()) & "000001"
end if
rs.close
conn.close
set rs = nothing
set conn = nothing
end sub