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

hello again i have a problem....

Status
Not open for further replies.

cazeno

Technical User
Jun 30, 2000
23
DE
hello

again i have a problem....i created some buttons to move through the recordset in the asp page. k problem is that if i click on a button not the next recordset i coming in the textfields .. no its going straight to the listbox menu´again. and so on. only if i click on submit in the form where the list box is the first record of the SQLQuery is shown in the textboxes..

can somebody look at the code ... and say what is wrong or how to solve that. hmmm would be great
caz


<%@LANGUAGE=&quot;VBScript&quot;%>
<!-- #INCLUDE VIRTUAL=&quot;adovbs.inc&quot; -->
<html>
<head>
<title>main</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#0066FF&quot; text=&quot;#000000&quot;>

<%If Request(&quot;tablename&quot;)=&quot;&quot; Then%>

<p><b><font size=&quot;+2&quot;>Please choose a table you want to display:</font></b></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form name=&quot;form&quot; method=&quot;post&quot; action=&quot;copy_cust_a.asp&quot;>
<div align=&quot;center&quot;>
<select name=&quot;tablename&quot; size=&quot;4&quot;>
<option value=&quot;item&quot; >item</option>
<option value=&quot;cust&quot; selected>cust</option>
<option value=&quot;prod&quot; >prod</option>
<option value=&quot;site&quot; >site</option>
</select>
<input type=&quot;submit&quot; name=&quot;Button&quot; value=&quot;Submit&quot;>
</div>
</form>
<%Else

DIM tablename
DIM SQLQuery

tablename = Request.Form(&quot;tablename&quot;)
set myConnection = Server.CreateObject(&quot;ADODB.Connection&quot;)
myConnection.Open &quot;DSN=ph;UID=sa&quot;
SQLQuery = &quot;select * from &quot; & tablename

if Request(&quot;tablename&quot;) = &quot;item&quot; Then
SQLQuery =&quot;select item_id,descr,serial from item&quot;
elseif Request(&quot;tablename&quot;) = &quot;cust&quot; Then
SQLQuery = &quot;select cust_id,descr,address,phone from cust&quot;

elseif Request(&quot;tablename&quot;) = &quot;prod&quot; Then
SQLQuery = &quot;select prod_id,descr from prod&quot;
elseif Request(&quot;tablename&quot;) = &quot;site&quot; Then
SQLQuery = &quot;select site_id,descr,address from site&quot;

end if

set rec = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rec.ActiveConnection = myConnection
rec.CursorType = adOpenKeyset
rec.CursorLocation = adUseClient
rec.LockType = adLockOptimistic

rec.MaxRecords = 10
rec.Open SQLQuery, myConnection
rec.MoveFirst

If Not IsEmpty(Request.Form(&quot;MoveAction&quot;)) Then
strAction = Request.Form(&quot;MoveAction&quot;)
varPosition = Request.Form(&quot;Position&quot;)

rec.AbsolutePosition = varPosition

Select Case strAction

Case &quot;MoveNext&quot;

rec.MoveNext
If rec.EOF Then
rec.MoveLast
strMessage = &quot;Can't move beyond the last record.&quot;
End If

Case &quot;MovePrev&quot;

rec.MovePrevious
If rec.BOF Then
rec.MoveFirst
strMessage = &quot;Can't move beyond the first record.&quot;
End If

Case &quot;MoveLast&quot;

rec.MoveLast

Case &quot;MoveFirst&quot;

rec.MoveFirst

End Select
End If

%>

<form name=&quot;form&quot; method=&quot;post&quot; action=&quot;copy_cust_a.asp&quot;>
<% for each field in rec.Fields %>
<table width=&quot;50%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; bordercolor=&quot;#000000&quot;>
<tr>
<td width=&quot;15%&quot;><b><font size=&quot;3&quot;><%=field.Name%></font></b></td>
<td width=&quot;85%&quot;>
<input type=&quot;text&quot; name=&quot;<%=field.Name%>&quot; VALUE=&quot;<%=field.Value%>&quot; size=&quot;40&quot;>
</td>
</tr>
</table>
<% next %>
<table width=&quot;16%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td width=&quot;10%&quot;>
<input type=&quot;Button&quot; name=cmdfirst value=&quot;&lt;&lt;&lt;&quot;>
</td>
<td width=&quot;10%&quot;>
<input type=&quot;Button&quot; name=cmdPrevious value=&quot;&lt;&quot;>
</td>
<td width=&quot;9%&quot;>
<input type=&quot;Button&quot; name=cmdNext value=&quot;&gt;&quot;>
</td>
<td width=&quot;71%&quot;>
<input type=&quot;Button&quot; name=cmdlast value=&quot;&gt;&gt;&gt;&quot;>
</td>
</tr>
</table>
</form>
<p>&nbsp;</p>
<%end if%>
<Form Method=Post
Action=&quot;<%=Request.ServerVariables(&quot;SCRIPT_NAME&quot;)%>&quot;
Name=&quot;form&quot;>
<Input Type=&quot;Hidden&quot; Size=&quot;4&quot; Name=&quot;MoveAction&quot; Value=&quot;Move&quot;>
<Input Type=&quot;Hidden&quot; Size=&quot;4&quot; Name=&quot;Position&quot; Value=&quot;<%= rec.AbsolutePosition %>&quot;>
</Form>

</body>
</html>
<Script Language = &quot;VBScript&quot;>
Sub cmdDown_OnClick
rec.MovePrevious
Document.Form.MoveAction.Value = &quot;MovePrev&quot;
Document.Form.Submit
End Sub

Sub cmdUp_OnClick
rec.MoveNext
Document.form.MoveAction.Value = &quot;MoveNext&quot;
Document.Form.Submit
End Sub

Sub cmdFirst_OnClick
rec.MoveFirst
Document.form.MoveAction.Value = &quot;MoveFirst&quot;
Document.Form.Submit
End Sub

Sub cmdLast_OnClick
rec.MoveLast
Document.form.MoveAction.Value = &quot;MoveLast&quot;
Document.Form.Submit
End Sub
</SCRIPT> [sig][/sig]
 
Your script does not work. I got some errors when I tried it.

1. <Input Type=&quot;Hidden&quot; Size=&quot;4&quot; Name=&quot;Position&quot; Value=&quot;<%= rec.AbsolutePosition %>&quot;> line is out of the <%If Request(&quot;tablename&quot;)=&quot;&quot; Then%> condition. If I run the script at the first time, I got message that &quot;Object Required&quot; because rec object is defined inside &quot;else&quot; condition.

2. You have
Sub cmdUp_OnClick and Sub cmdDown_OnClick
but the buttons are cmdPrevious and cmdNext

3. I am not sure that it is because of my set up or not because you said that it works on your system but not the way you want. However, the <script language=VBScript> part does not work. When I clicked on the buttons, I got message of &quot;Object Required&quot;. Look like it now is Client Side Script where you don't have CreateObject.

I am new in ASP, if anyone thinks that I am wrong, please let me know.

Thanks.



[sig][/sig]
 
yeah but afterall i deleted the rows
rec.AbsolutePosition
but how should i write that with the buttons i mean
its still going the show me the listbox and not the next record
....hmmm i dont know
please help [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top