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!

Count records in table of a database.

Status
Not open for further replies.

JeroenDortmans

Technical User
Aug 7, 2001
56
NL
What I want to do:

In table 1 I have a field named "person_ID".
I have a table 2 which is related to table 1 with the same field named "person_ID".
On the first page (form) I have information from table 1. The second page (form) has information of table 2.

What I want to know:
I have placed a button on page 1. With this button I want to go to the information with the related person_ID on page 2, only when there is a related person_ID in table 2. When the same person_ID in table 2 doesn't exist, promt a MsgBox.

Can somebody help with the VBS-code I need for this?!

 
For server side:

<script language=VBScript>
Sub button_onclick
<%
Dim table2RS
table2RS = conn.Execute(&quot;select person_ID from table2 where person_ID = &quot; & personID)
If table2RS.EOF Then%>
MsgBox &quot;No person_ID for person &quot; & personID
<%Else%>
document.location = &quot;page2.asp&quot;
<%End If%>
End Sub
</script>


For client side:

<script language=VBScript>
Sub button_onclick
Dim table2RS
table2RS = RDSobject.Query(&quot;select person_ID from table2 where person_ID = &quot; & personID)
If table2RS.EOF Then
MsgBox &quot;No person_ID for person &quot; & personID
Else
document.location = &quot;page2.asp&quot;
End If
End Sub
</script>


Hope it helps &quot;A computer scientist is a person who knows when it is time to hit the computer.&quot;

John

johnmc@mvmills.com
 
Thank you John for your help. But this doesn't work
I use data access pages (made with MS Access 2000).
With this VBS I get the message &quot;Object needed&quot; (translated from Dutch). Can you or anybody else help me please!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top