Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

rst.Seek

Discussion in 'Information Technology' started by - Alex, Jul 28, 2006.

Tags:
  1. - Alex

    - Alex
    Expand Collapse
    Guest

    If anyone can help me with this function it would help a lot

    I am running some access code to use a table, divided into 7 parts (separate
    tests we'll say) using a field to number each test. I am using them in code
    to fill in a table that will show the person with all 7 tests in a line going
    across but not all people on the table have 7 tests, some don't even have any.

    I have most of the code down and working but for that I need an rst.Seek
    statement for a rst.NoMatch. I need it to work so that when the loop goes
    thru it realizes the record set is blank and I don't get a "No current
    Record" error. The Problem is when I try to use the Seek function I get
    "Operation is not supported for this object type"

    The code is as follows:

    Dim rtest As Recordset 'Table used to test for existing tests

    Do While Not (rst.EOF)
    'Test tests 1 - 7 for Per#, If they have it then I attach data in
    proper columns
    For i = 0 To 6
    'Select statement to find Per# matching the current Person
    qry = "SELECT " & test(i) & ".Date, " & test(i) & ".Result, " &
    test(i) & ".Percent, " & test(i) & ".PerNumber FROM " & test(i) & " WHERE
    (((" & test(i) & ".PerNumber)=" & rst![PerNumber] & "));"

    Set rtest = db.OpenRecordset(qry)

    rtest.Seek "=", rst![CPLNumber] ‘This is the problem statement

    If rtest.NoMatch Then
    i = 6 'This is what exits the for loop
    Else

    That is followed by simply writing the data to the table and moving to the
    next person.

    If anyone can explain this rst.seek method or perhaps another function that
    will give the same result, it would be more than appreciated.
     
  2. Yanick

    Yanick
    Expand Collapse
    Guest

    Try replace the seek function by the FindFirst function.

    If the function find a record matching your critérias, it will automaticaly
    position it-self to the founded record. If not, the .nomatch properties will
    be trigger.

    Hope it will work.

    "- Alex" wrote:

    > If anyone can help me with this function it would help a lot
    >
    > I am running some access code to use a table, divided into 7 parts (separate
    > tests we'll say) using a field to number each test. I am using them in code
    > to fill in a table that will show the person with all 7 tests in a line going
    > across but not all people on the table have 7 tests, some don't even have any.
    >
    > I have most of the code down and working but for that I need an rst.Seek
    > statement for a rst.NoMatch. I need it to work so that when the loop goes
    > thru it realizes the record set is blank and I don't get a "No current
    > Record" error. The Problem is when I try to use the Seek function I get
    > "Operation is not supported for this object type"
    >
    > The code is as follows:
    >
    > Dim rtest As Recordset 'Table used to test for existing tests
    >
    > Do While Not (rst.EOF)
    > 'Test tests 1 - 7 for Per#, If they have it then I attach data in
    > proper columns
    > For i = 0 To 6
    > 'Select statement to find Per# matching the current Person
    > qry = "SELECT " & test(i) & ".Date, " & test(i) & ".Result, " &
    > test(i) & ".Percent, " & test(i) & ".PerNumber FROM " & test(i) & " WHERE
    > (((" & test(i) & ".PerNumber)=" & rst![PerNumber] & "));"
    >
    > Set rtest = db.OpenRecordset(qry)
    >
    > rtest.Seek "=", rst![CPLNumber] ‘This is the problem statement
    >
    > If rtest.NoMatch Then
    > i = 6 'This is what exits the for loop
    > Else
    >
    > That is followed by simply writing the data to the table and moving to the
    > next person.
    >
    > If anyone can explain this rst.seek method or perhaps another function that
    > will give the same result, it would be more than appreciated.
     
  3. BAC

    BAC
    Expand Collapse
    Guest

    You have not declared the Index to be used. Seek requires an active index.
    you get the error you get (I would think) because, it appears, you're
    recordset is a query result and not a table.

    The Find First method suggested by yanick should work for you here


    "- Alex" wrote:

    > If anyone can help me with this function it would help a lot
    >
    > I am running some access code to use a table, divided into 7 parts (separate
    > tests we'll say) using a field to number each test. I am using them in code
    > to fill in a table that will show the person with all 7 tests in a line going
    > across but not all people on the table have 7 tests, some don't even have any.
    >
    > I have most of the code down and working but for that I need an rst.Seek
    > statement for a rst.NoMatch. I need it to work so that when the loop goes
    > thru it realizes the record set is blank and I don't get a "No current
    > Record" error. The Problem is when I try to use the Seek function I get
    > "Operation is not supported for this object type"
    >
    > The code is as follows:
    >
    > Dim rtest As Recordset 'Table used to test for existing tests
    >
    > Do While Not (rst.EOF)
    > 'Test tests 1 - 7 for Per#, If they have it then I attach data in
    > proper columns
    > For i = 0 To 6
    > 'Select statement to find Per# matching the current Person
    > qry = "SELECT " & test(i) & ".Date, " & test(i) & ".Result, " &
    > test(i) & ".Percent, " & test(i) & ".PerNumber FROM " & test(i) & " WHERE
    > (((" & test(i) & ".PerNumber)=" & rst![PerNumber] & "));"
    >
    > Set rtest = db.OpenRecordset(qry)
    >
    > rtest.Seek "=", rst![CPLNumber] ‘This is the problem statement
    >
    > If rtest.NoMatch Then
    > i = 6 'This is what exits the for loop
    > Else
    >
    > That is followed by simply writing the data to the table and moving to the
    > next person.
    >
    > If anyone can explain this rst.seek method or perhaps another function that
    > will give the same result, it would be more than appreciated.
     

Share This Page