Results 1 to 2 of 2
  1. #1
    Join Date
    May 2014

    Question Unanswered: Conditional checking in Access 2010 web-compatible macros

    Good morning,

    I am currently working on a database with a form where I've created buttons to go to the next/previous record. However, if I am at the top of the table and click "Previous" (or the bottom of the table an click "Next") I get a macro error "2105" basically telling me what I already know (that I'm at the top/bottom of the table).

    So the obvious thing to do would be to use conditional statements to check for this and react accordingly. Now in languages where you can actually type out the code, this is uber-simple "programming 101" stuff. If-statements are really no big deal... when you can actually write them. But as this is a web database, I'm stuck with the cruddy drop-&-drag visual thing instead, so I'm not even sure if this is possible (though I'm sure there's got to be a way).

    So I spent way too much time Googling around looking for a similar answer, but with no usable results (most "hits" led to sites that either used VBA code or dealt with questions that were completely unrelated). So, any suggestions would be greatly appreciated.

    What I'd like to do is something like this:

    'This is just an example of what I'm trying to do;
    'I am very familiar with VBA but more in Excel, so as you'll see this is
    'not actual working Access VBA code (sorry for inconvenience).
    'For "previous" button
    If CurrentRecord = FirstRecord Then
    End If
    'For "Next" button
    If CurrentRecord = LastRecord Then
    End If
    This way, the buttons would loop through the records without giving the end users a macro error.

  2. #2
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    Like most of the experienced people, here, I almost never use Macros, but I noodled around and this works for the Previous Record Button:

    Cond: [NewRecord] = True
    Action: GoToRecord
    Action Argument (Record): Last

    Cond: [CurrentRecord]=1
    Action: GoToRecord
    Action Argument (Record): Last

    Cond: [NewRecord] <> True
    Action: GoToRecord
    Action Argument (Record): Previous

    Cond: [CurrentRecord]<>1
    Action: GoToRecord
    Action Argument (Record): Previous

    While the Arguments appear in the right hand column in Macro Design, you have to go to the lower part of the window and enter them in the 'Action Argument' section under 'Record.'

    Name your Macro something like PrevRecord, and then in Form Design View, simply enter PrevRecord in the OnClick Property of your Command Button.

    Macros for the other buttons can be done in a similar fashion.

    'Wrapping' the Records, when you get to the last one or the first one, as you're doing, is something I've done routinely for years, rather than popping a message.

    Linq ;0)>
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Tags for this Thread

Posting Permissions

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