Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Required

Status
Not open for further replies.

crjo

Programmer
Jul 3, 2001
15
US
Get 'Object Required' error on the first line of my IF statement:
<%
IF (rsRoomRoster.Fields.Item("RoomHoldDate").Value IS NOT NULL) AND (rsRoomRoster.Fields.Item("AdmissionDate").Value IS NULL) THEN
Response.Write("<td>")
Response.Write(rsRoomRoster.Fields.Item("ResName").Value)
Response.Write("Room on Hold")
Response.Write("</td>")
ELSE
Response.Write("<td>")
Response.Write(rsRoomRoster.Fields.Item("ResName").Value)
Response.Write("</td>")
END IF
%>
Take out the statement and it everything works fine. Tried Dim, As String, Len, etc. Same error.
SQL is calling stored proc. Using Dreamweaver MX 2004.
 
Crjo,

Hate to ask but did you create the recordset?

Set objConn = Server.CreateObject("ADODB.Connection")
Set rsRoomRoster = Server.CreateObject("ADODB.Recordset")

Did you open the sql?

rsRoomRoster.Open strSQL, objConn

Could you show your db connection and rs code?
Looks good to me...perhaps missing something there or try shortening code...

Code:
<%
IF rsRoomRoster("RoomHoldDate") <> NULL AND isNull(rsRoomRoster("AdmissionDate")) THEN 

Response.Write "<td>" & rsRoomRoster("ResName") & " Room on Hold</td>"

ELSE
Response.Write "<td>" & rsRoomRoster"ResName") & "</td>"
END IF
%>


 
Or, maybe this would be better? (Because checking null using <>null will always result in null).
[tt]
IF (Not isNull(rsRoomRoster("RoomHoldDate"))) AND isNull(rsRoomRoster("AdmissionDate")) THEN
[/tt]
- tsuji
 
tsuji, thanks for your help (you too bslintx!)
This worked:
<%
IF (Not isNull(rsRoomRoster("RoomHoldDate"))) AND isNull(rsRoomRoster("AdmissionDate")) THEN
Response.Write "<td>" & rsRoomRoster("ResName") & " Room on Hold</td>"
ELSE
Response.Write "<td>" & rsRoomRoster("ResName") & "</td>"
END IF
%>
 
Glad it worked, remember...asp has a lot of shortcuts...no need to put all the unnecessary response.writes (server trips)and also querystring can be written w/o querystring but need .form for post method. Thanks for the recognition. :)

BSL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top