Macro Condition

  • Thread starter Thread starter hogan
  • Start date Start date
H

hogan

I have the following tables.

tblPartsInv
Part Invoice # (primary)
Date Created
Date Required
Work Order ID (foreign)

tblWordOrder
Work Order ID (Primary
Date Created
Due Date
Work Required

I am using a button on a Work Order form to open a Parts Invoice form using
the following Where Conditoin.

Where: [Forms]![SERVICE WORK ORDERS]![WORK ORDER ID]

This works great when a parts invoice was previously created by our parts
department and data is in the Work Order ID field.

What I want to be able to do is when the button on my Work Oder form is
pressed and the Where Conditon above is not true (no Parts Invoice has not
been previously created), I would like a new parts invoice automatically
created for that work order using the relationship between the Work Order Id
on both tables.

Hopefully this makes sense.

Thank you
 
Hogan,

You will need to explictly force the creation of the matching record if it
doesn't already exist. This can't be done via the Where Condition argument
of the OpenForm action.

Use a Condition in your macro like this:
DCount("*","tblPartsInv","[Work Order ID]=" & [WORK ORDER ID])=0
.... for an OpenQuery action that runs an Append Query to add the new record
to the tblPartsInv table.

Put this into your macro prior to the OpenForm action.

Hope that makes sense.

--
Steve Schapel, Microsoft Access MVP


hogan said:
I have the following tables.

tblPartsInv
Part Invoice # (primary)
Date Created
Date Required
Work Order ID (foreign)

tblWordOrder
Work Order ID (Primary
Date Created
Due Date
Work Required

I am using a button on a Work Order form to open a Parts Invoice form
using
the following Where Conditoin.

Where: [Forms]![SERVICE WORK ORDERS]![WORK ORDER ID]

This works great when a parts invoice was previously created by our parts
department and data is in the Work Order ID field.

What I want to be able to do is when the button on my Work Oder form is
pressed and the Where Conditon above is not true (no Parts Invoice has not
been previously created), I would like a new parts invoice automatically
created for that work order using the relationship between the Work Order
Id
on both tables.



__________ Information from ESET Smart Security, version of virus signature database 4202 (20090630) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
Back
Top