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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicate action from db to asp using If null

Status
Not open for further replies.

annalyst

IS-IT--Management
Nov 16, 2003
4
US
I am using this code in an Access database to have a command button (stop sign) appear if there are any records in a specific query. (queried by <Date()).

If Nz(DCount(&quot;*&quot;, &quot;OTP-2 StopError&quot;), 0) > 0 Then
cmdOTP2SE.Visible = True
OTP2.Visible = False
Else
cmdOTP2SE.Visible = False
OTP2.Visible = True
End If

I have the same structure on an html page that has command buttons that call data access page with the queries. I'm at a loss, this is not my area, I usually just put the databases together. Will this code work with asp and can it perform the same function?
Thanks for any help Annalyst
 
Yes, you can do same thing in asp but in a diferent way.
Code:
Database and ASP page must be in same directory
<%
Set con=Server.CreateObject(&quot;ADODB.Connection&quot;)
dbPath=Server.MapPath(&quot;yourdb.mdb&quot;)
con.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & dbPath
set rs=server.CreateObject(&quot;ADODB.Recordset&quot;)
sql=&quot;select * from OTP-2 StopError&quot;
rs.Open sql,con,3,3

if rs.RecordCount>0 then
'we write the html equivalent to an single button(visible one)
%>
 <input type=button value=&quot;Stop 1&quot; name=cmdOTP2SE>
<%
else
%>
 <input type=button value=&quot;Stop 2&quot; name=OTP2>
<%
end if
%>
This should do it.
Also you would need more then that if you want the buttons to have some action.

________
George, M
 
I got a connection today using an asp page but here is the problem when I open the page I only want to see the stop buttons that actually have records in it. (12 stop signs and 12 caution signs connected to 24 access pages each calling up a different query. Only maybe 5 out of these contain records at any given time and that's all that should show up.)
The data access pages are linked to the database, both the data access pages the asp page are in the same folder.
I used a code like this as part of the asp code (sorry I'm building this at work and now I'm at home and don't have the exact code)

If rsCount(&quot;OTP2&quot;)>0 then
imgStop.visible = true
Else rsCount(&quot;OTP2)<0 then
imgStop.visible = false

I thought this would be easier to go through the access pages, but now I'm not to sure.
Thanks for responding to this post.
Mary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top