need to update another open form

G

Guest

Can you tell me how to write code for the following;
after update
While I am in frmRepairs and frmCustomerEquipment is also open.
I have a checkBox field to indicate if this is a "preventative maintenance"
(named "PM") type of repair.
and I have a DateCompleted field.

if PM= true and DateCompleted is not null then
update the field in frmCustomerEquipment called LastPMDate with the
date in frmRepairs, DateCompleted

frmCustomerEquipment is open and we have a button to go to
frmRepairs.

Appreciate your help, KPE
 
J

John Nurick

Hi KPE,

A better approach in a relational database is not to store LastPMDate at
all, but instead look it up whenever needed. That way you're never
storing two separate pieces of data that refer to the same real-world
fact - with the possibility this offers for them getting out of sync).

So I wouldn't use a LastPMDate field at all in the table on which
frmCustomerEquipment is based. Instead, I'd have a textbox txtLastPMDate
on the form, with an expression in it like this:

=DMAX("DateCompleted", "Repairs", "(EquipmentID=" & [EquipmentID] & ")
AND (PM=True)")

Obviously you need to replace EquipmentID with the name of the actual
field that relates Repairs to Equipment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top