Welcome to SPN

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

Sign Up Now!

RE: debug error on ".MoveFirst" statement

Discussion in 'Information Technology' started by Ken Higgins, Jul 28, 2006.

  1. Ken Higgins

    Ken Higgins
    Expand Collapse
    Guest

    Sorry I have been unavailable since your last post.
    I took my original code off of the web site and it required some
    substantial editing to make it work like i posted it.

    Seems like the site chopped off some of the
    line continuations. The movefirst is probably unnecessary since,
    as Doug Steele says, it opens to the first record. He's right. So
    perhaps the movefirst is not necessary.

    With respect to your observation as to why the .movefirst
    command seems to render "none of the
    ..Move commands are available" - I dont understand what is going on
    there. But if the code works "fine" as you say -- then use that to get started
    and be creative from there.

    Hopefully by now, you have been able to work this through.
    Come back if not.

    "CityGuy" wrote:

    > I copied your subroutine into my code, but had to comment out
    > my original .MoveFirst statement to get the code to compile.
    >
    > I noticed that if I tried to enter an new .MoveFirst command in my
    > original code, none of the .Move commands are available.
    >
    > Your code though works FINE. (all .move commands are available)
    >
    > What is going on?
    >
    > "Ken Higgins" wrote:
    >
    > > I wrote a little program to try to simulate your problem and came to the
    > > conclusion that it is probably in the options, or lockedits portion of your
    > > code that is causing
    > > the problem. I cant believe its the DAO version you are using.
    > >
    > > The help files are not very easy to understand with all of the "settings"
    > > that you can optionally use. Try doing something very simple with the
    > > openrecordset statement and get it to work first. Then you can better try the
    > > more advanced setting combinations (if you really need them) --- less is
    > > often better than more!
    > >
    > > Here is a simple program to try (Oh by the way - if you try this program you
    > > will also discover the frailty of the RECORDCOUNT property no matter how many
    > > records you add :) IT works after the record is added - but not before
    > > (because the record is added to the end of the recordset) But that was not
    > > the problem you mentioned.
    > >
    > > Public Sub test()
    > >
    > > Dim db As DAO.Database
    > > Dim currYr As DAO.Recordset
    > > Dim vReturn As Variant
    > > Dim lngCounter As Long
    > >
    > > Set db = CurrentDb()
    > > Set currYr = db.OpenRecordset("tblCurrentYear", dbOpenDynaset)
    > > currYr.Close
    > > With currYr
    > >
    > > Debug.Print "BEFORE ADD: Recordset has: " & CStr(.RecordCount) & "
    > > Records"
    > > If .EOF Or .BOF Then
    > > vReturn = MsgBox("Cant Move to an empty recordset" & _
    > > vbCrLf & "Hit OK to Continue or CANCEL to Quit",
    > > vbExclamation + vbOKCancel, _
    > > "Ask User Something")
    > > If vReturn = vbNo Then GoTo DoSomethingElse
    > > End If
    > > ' .MoveFirst 'i commented this line out
    > > .AddNew
    > > !txtTestfld1 = "Record " & CStr(.RecordCount + 1)
    > > .Update
    > > Debug.Print "AFTER ADD: Recordset has " & CStr(.RecordCount) & "
    > > Records"
    > >
    > > .MoveFirst
    > > End With
    > >
    > > DoSomethingElse:
    > > currYr.Close
    > > Set currYr = Nothing
    > > db.Close
    > > Set db = Nothing
    > > End Sub
    > >
     
  2. Loading...


Share This Page