Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Aug 2002
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to Use DoCmd (2K)

    The Help files say that the offset for this command can be an expression, as long as that expression evaluates to an integer.
    DoCmd.GoToRecord , , acNext, 7 --> This works beautifully

    DoCmd.GoToRecord , , acNext, x --> Doesn't work. (x is assigned an integer value)

    The Help files also say that for an expression to be used it must be preceded by an equal sign. I have been unable to get this to work no matter where I place the =.
    How do I get this to work?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How to Use DoCmd (2K)

    You say that x is assigned an integer value, but is x declared as an integer? Is the value a valid one in the recordset? Since there isn't any reason what an integer variable named X should fail, I have to assume something else is going on.
    Charlotte

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: How to Use DoCmd (2K)

    When I tried this it worked perfectly

    Dim X As Integer
    X = 5
    DoCmd.GoToRecord , , acNext, X

    How did you assign a value to X?
    Regards
    John



  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: How to Use DoCmd (2K)

    You wrote: "The Help files also say that for an expression to be used it must be preceded by an equal sign. I have been unable to get this to work no matter where I place the =." In what context would you use DoCmd with an equal sign?? I've never seen DoCmd used in that way.

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to Use DoCmd (2K)

    Did one help item tell you both that you can use an expression in DoCmd and that you need to precede expressions with an =? I suspect that you've been looking at more than one help item and getting confused. There are circumstances where you need to precede an expression with an = (notably when you want to use an expression as a control source), but DoCmd isn't one of them.

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How to Use DoCmd (2K)

    You place the = like this:

    Dim x As Integer
    x = 7

    DoCmd.GoToRecord , , acNext, x

    If that doesn't work, you have some other problem.
    Charlotte

Posting Permissions

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