Welcome to SPN

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

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

RE: debug error on ".MoveFirst" statement

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

  1. Ken Higgins

    Ken Higgins
    Expand Collapse

    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...

Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     

Share This Page