subform with two requirements and 2 fields

D

deb

I have a subform that is a continuous form(PK ProjectID). The record source
is a query that limits the field called KeyMilestonesSubID to a choice of 15
or 22.

Ther fields are ProjectID, KeyMilestonesSubID, Unit, ActualDt and OrigDt.

How do I make it a requirement that the user enter KeyMilestonesSubID and
ActualDt for both selections- 15 and 22?

They must select KeyMilestonesSubID 15 and ActualDt and they must also
select KeyMilestonesSubID 22 and the ActualDt
 
S

SuzyQ

in the before update event you could do something like this...

if len(KeyMilestonesSubID ) <> 15 and len(KeyMilestonesSubID ) <> 22 then
msgbox "invalid id"
cancel = true
endif
 
D

deb

Tried it in before update of the form and also before update of the field
KeyMilestonesSubID
did now work - nothing happened
wondering why use len and why <>?

There is only two choices in the drop down 15 and 22.
I want to make it where the must select 15 from dropdown KeyMilestonesSubID
and enter data in ActualDt
then they must also
select 22 from dropdown KeyMilestonesSubID and enter data in ActualDt

They must enter both in the continuous form or they get an msg box saying to
enter both
 
F

Frank H

If you haven't gotten your problem solved yet, be sure to specify what
version of Access you are using, and explain what you are doing:
Is this all about when you are trying to edit a record in the subform? Add a
new record? What is going on in the main form?

If it is for editing, one approach might be:
NameofSubform_BeforeUpdate(Cancel as integer)
if me.KeyMilestonesSubID = 15 and not isnull(me.actualDT) then exit sub
if me.KeyMilestonesSubID = 22 and not isnull(me.actualDT) then exit sub
Cancel = true
msgbox "You must enter either 15 or 22 in keyMilestone, AND the actual
date"
end sub
 

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