Find Record

Results 1 to 3 of 3

Thread: Find Record

  1. #1
    Join Date
    Dec 1969

    Default Find Record

    I have this section of code that seems like alot of overhead for nothing: Here it is:While Not objRec.EOF<BR><BR> If objRec.Fields("UserName") = UserName Then<BR> FirstName = objRec.Fields("FirstName")<BR> LastName = objRec.Fields("LastName") <BR> End If<BR> objRec.MoveNext<BR>Wend<BR><BR>I would like to use the following code:<BR><BR>objRec.Find "UserName = &#039theuser&#039"<BR>FirstName = objRec.Fields("FirstName")<BR>LastName = objRec.Fields("LastName") <BR><BR>This works, but I cannot get it to work using a variable. I would like it so do the following:<BR><BR>objRec.Find "UserName = " & Session.Contents("UserName")<BR><BR>This will not work. Is there anyway to have it work with a variable instead of just a string? The reason I want to do this is so that it stays on this record once its found.<BR><BR>TIA<BR>

  2. #2
    Neil Popham Guest

    Default RE: Find Record

    im not really familiar with &#039.find&#039, but is it possible that the line should be:<BR><BR>&#062; objRec.Find "UserName = &#039" & Session.Contents("UserName") & "&#039"<BR>

  3. #3
    Neil again Guest

    Default RE: Find Record

    you could always use<BR><BR>&#062; "SELECT FirstName, LastName FROM MyTable WHERE UserName=&#039" & Session("UserName") & "&#039"<BR><BR>...check that a record has been returned<BR><BR>&#062; If Not objRec.EOF Then<BR>&#062; FirstName = objRec.Fields("FirstName")<BR>&#062; LastName = objRec.Fields("LastName") <BR><BR>etc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts