Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Location
    Lebanon
    Posts
    44

    Unanswered: Problems in using acLast

    Hi
    I have a form linked to a table that contains 10 records.
    I'm using in the form a for to next loop as follows

    for x=0 to acLast
    MsgBox (acLast)
    Next x

    The MsgBox returns acLast as 3 while It should be 10 because there are 10 records in the table. Does anyone know why?
    Dani_30

  2. #2
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    aclast is an intrinsic constant with the value 3

    acFirst = 2
    acGoTo = 4
    acLast = 3
    acNewRec = 5
    acNext (default) = 1
    acPrevious = 0


    try something like this

    rst.MoveLast
    rst.MoveFirst
    Msg Box rst.RecordCount

    or

    SELECT COUNT(*) FROM table_name to get a record count



    Assign the result to your end limit of the for...next statement


    Matt

  3. #3
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369
    Thanks for excellent descriptions

    kedaniel

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: Problems in using acLast

    Originally posted by stc834
    Hi
    I have a form linked to a table that contains 10 records.
    I'm using in the form a for to next loop as follows

    for x=0 to acLast
    MsgBox (acLast)
    Next x

    The MsgBox returns acLast as 3 while It should be 10 because there are 10 records in the table. Does anyone know why?
    You can use something like that:

    Dim rs As Recordset, i as long
      Set rs = Me.RecordsetClone
      rs.MoveLast
      for i= 1 to ff.RecordCount
         ' Your Code
      Next

Posting Permissions

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