Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Aug 2001
    Darkest Kent, UK., Kent, England
    Thanked 0 Times in 0 Posts

    Get...If..ElseIf...Next (Access '97 & W95b (!))

    What I'm looking for is a way of selecting the next entry from a table and run a specific macro depending on a specific field value.

    i.e. Data Source Table

    Seq No Category
    1000 A1
    1001 B1
    1002 A2
    1003 C1
    1234 A2

    A rough idea of what I'm looking for is as follows: (excuse deplorable syntax and incorrect keywords)


    Get Seq No '(start with the first item in the table)

    If Category = "A*" '(incorporates A1 and A2)
    DoCmd RunMacro "Macro A"
    ElseIf Category = "B*"
    DoCmd RunMacro "Macro B"
    ElseIf Category = "C*"
    DoCmd RunMacro "Macro C"

    Next Seq No '(continue until last in table has been processed)


    There are only one of three types of category (A*, B* & C*) and the Seq No's are sequential, in that where the run for one month finishes, the following month picks up from.

    Please help. I'm driving myself <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15> with this. Sorry about the cack formatting - I thought it'd look better than this.


  2. #2
    4 Star Lounger
    Join Date
    Feb 2001
    Richland, Washington, USA
    Thanked 0 Times in 0 Posts

    Re: Get...If..ElseIf...Next (Access '97 & W95b (!))

    Are you looking for the specifc syntax that would accomplish what you've outlined or are you wondering if you are conceptually on the right track?

    You could use something like (using DAO, not ADO):

    Set rst = CurrentDb.OpenRecordset("SourceTable")

    Do While Not rst.EOF
    DoCmd.RunMacro "Macro " & Left(rst!Category,1)


    This is probably the tip of the iceberg, though. Do you need to reference the table data for the current record in the table?

    You might also consider biting the VBA bullet and use VBA code instead of a macro as it gives you a lot more flexibility.

Posting Permissions

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