Re: rs.Skipfirst??

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Bob Barrows (reb01501_at_NOyahoo.SPAMcom)
Date: 02/25/04


Date: Wed, 25 Feb 2004 11:06:48 -0500

Bryan Harrington wrote:
> Ok.. so I'm using a .CLASSIC Sub that basically returns a datagrid
> that is sortable and does paging. It's very handy since it's fairly
> generic in that I can pass it a SQL query and it populates the
> datagrid using the database field names as column headings.
>
> So.. my problem, I need the ID of record so I can pass it on the QS
> to an edit page, but I don't want to display it as the first column.
>
> Below is the snippet of code, and it does a for each field in
> RS.Fields... how do I say skip the first item in the collection?
>
> Thanks!
>
> 'display from the current record to the pagesize
> for i = intCurrentRecord to RS.PageSize
> if not RS.eof then
> Response.Write "<tr>" & vbcrlf
>
> 'for each field in the recordset
> for each field in RS.Fields
> Response.Write "<td>" & vbcrlf
>
> 'if this field is the "linked field" provide a link
> if lcase(strLinkedColumnName) = lcase(field.name) then
> Response.Write "<a href=" & strLink & rs("id") & ">" & field.value
> & "</a>" & vbcrlf
> else
> Response.Write field.value
> end if
> Response.Write "<td>" & vbcrlf
> next
> Response.Write "<tr>" & vbcrlf
> RS.MoveNext
> end if
> next

Two choices:

for each field in RS.Fields
    If field.name <> "ID" ' or whatever the name of it is
        'do the write
    end if
next

or

for iCol = 1 to RS.Fields.count - 1
    set field=RS.Fields(iCol)
    'etc.
next

HTH,
Bob Barrows
PS. You should not use the word "field" as a variable name - avoid names of
intrinsic objects when naming your variables - I usually use "fld"

-- 
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Relevant Pages

  • Re: rs.Skipfirst??
    ... It's very handy since it's fairly generic in ... > field names as column headings. ... but I don't want to display it as the first column. ...
    (microsoft.public.inetserver.asp.general)
  • rs.Skipfirst??
    ... I can pass it a SQL query and it populates the datagrid using the database ... field names as column headings. ... but I don't want to display it as the first column. ...
    (microsoft.public.inetserver.asp.general)
  • Re: "2-Way" Lookup?
    ... I'm not sure if you still had a question about the last zero in the formula ... That formula (with an exact match) returns "e" ... The display column headings in Display!B1:D1 ... The information from Access is very simple: My column headings are ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Auto populate field
    ... the first column ... it's the second column that will be displayed to the user (in your case, ... If you want to display more than one column when the combox is rolled down ... the second column of the combobox and set its width to a very small value ...
    (microsoft.public.access.adp.sqlserver)
  • Re: "2-Way" Lookup?
    ... The display column headings in Display!B1:D1 ... I have a worksheet that adds one column of data ... The information from Access is very simple: My column headings are ... number of sales for that store on that day. ...
    (microsoft.public.excel.worksheet.functions)