Macro Troubles

  • Thread starter Thread starter James Miley
  • Start date Start date
J

James Miley

I am currently using MS Access XP for a form I use for work for books that
are on a circuit.

I have 6 Statuses for each book:

Received
Sent
To be Repaired
Did Not Receive
Checked Out
Lost

I set up a Macro that when a book has the Received Status, Focus will switch
to the next record. (this saves me from hitting the tab a few times to
bypass ID#, Circ, and Due Date).

The Macro has the Condition [Forms]![Master Status]![Status]="Received"
and action of GoToRecord (next one)

The Macro is attached to the On Lost Focus on the Status field

However, I want the same action to be done when the Status is Did Not
Receive so I change the condition to:
[Forms]![Master Status]![Status]="Received" Or "Did Not Receive"

Once I do this though, It will always skip to the next record regardless of
the Status and when I click into another box, the cursor just goes to the
next record.

If I create a separate macro entry for Did Not Receive, it will only skip to
the next record for Received.

I hope all of this makes sense and any help would be wonderful. I have been
messing around with this for the past week and just have decided to ask for
help.

If there is anything that needs cleared up, feel free to e-mail me or post a
message. I'll try and be prompt in my response (e-mail probably quicker).

Thanks in advance.

J. Miley
(e-mail address removed)
 
James,

You have to fully express the Condition in your macro. When you put:
[Forms]![Master Status]![Status]="Received" Or "Did Not Receive"
.... Access diesn't know what the "Did Not Receive" refers to, as it's
just hanging in space. It has to be more like this...
[Forms]![Master Status]![Status]="Received" Or [Forms]![Master
Status]![Status]="Did Not Receive"
However, since the macro is being called from the Master Status form
itself, there is no need to qualify the form name in the macro
condition, so try...
[Status]="Received" Or [Status]="Did Not Receive"
Another approach would be...
[Status] In("Received","Did Not Receive")

- Steve Schapel, Microsoft Access MVP
 
This could work:

Change the Condition to: [Forms]![Master Status]![Status]="*Receive*"

Let me know if it works
 
Your problem is in your logic.. change your condition to
[Forms]![Master Status]![Status]="Received" Or *[Forms]![Master
Status]![Status]=*"Did Not Receive"

and it should work. I've bolded the new text.

Basically you have to regard each part of the logical sentence as being
complete, and putting just "Did Not Receive" is the same as asking "Is
the string 'Did Not Receive' not null?" which isn't what you meant.
It's a bit hard for me to explain but it's just a way in doing this
sort of logic.
 
Back
Top