Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2006
    Posts
    28

    Unanswered: Conditional macros

    I'm pretty new to this and am having loads of problems with applying conditional macro's
    I want to write a macro that opens a table, looks for a record, if a field in the record is blank then I want it to open a certian report and if it is not then I want it to open another report. But I don't really know where to start.
    when I write a condition Tables![tb:sales][cust tag no] is null, a message box appears saying it can't find Table, and if I delete table it can't find tb:sales

    Any clues?!

    Thanks!

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    My strong recommendation would be to skip the macro. Jump into VBA; your learning curve may be a little steeper, but you'll be far better off in the long run. This is simple to do in VBA. You can use a recordset or DLookup to find the table value, and an If/Then statement to do the logic.
    Paul

  3. #3
    Join Date
    Oct 2006
    Posts
    18

    Perhaps this

    On my condition line I put

    IsNull([Tables]![tb:sales]![Cust tag no])

    then the action.

    Remember in the next line where you put action for what to do if it isn't null, put 3 dots in the condition line indicating this next action is attached to the above condition.

    Some of us don't know VBA...and at my age it might be like learning Chinese.
    Hope this helps...j

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I hope you're really old to say that! In any case, if you don't know macros and you don't know VBA, you're far better off learning VBA.

    I was unaware that you could refer directly to a table field in a macro condition, though since I don't use them I wasn't sure. I tested that condition and got an error that it couldn't find "Tables", so I'd be interested to hear if that actually works.
    Paul

  5. #5
    Join Date
    Oct 2006
    Posts
    18

    Condition Macro

    Sorry, you're absolutely right. Conditions don't recognize tables. I've always used forms, and it works fine - stupidly assumed it would work on tables too - see I told you I was old.

    Create a form from your table using pertinent data ("selection" field and "customer tag no" field at least).

    Make a "Picklist" combo box on the "selection" field to select which record you want a report on.

    "After Update" macro to find record = "Picklist" and open report based on Customer tag field

    Condition-----------------------------------------Action--------Parameter
    ----------------------------------------------GotoControl----Selection field
    -----------------------------------------------FindRecord------=Picklist
    -----------------------------------------------GotoControl----Cust Tag No
    IsNull([Forms]![frmNameofForm]![Cust Tag No] Open Report-----Report1
    ...--------------------------------------------Open Report-----Report2


    I'm assuming you want some way to select a particular record. You'll be able to use the form to do that easily. If you want to select all records that are null, I'm sure VBA is the only way to go.

    Again, sorry for the mistake....

  6. #6
    Join Date
    Sep 2006
    Posts
    28
    Thanks very much for your help, that works perfectly!!

Posting Permissions

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