Help! How do you make a form Invisible based on a conditional field

M

Marco

Hi everyone
This is my first post so bear with me. My form contains three Table

1st Table is "ClientDB" with a U-Key autonumbered "ClientID"

2nd Table is "PolicyDetails" with a U-Key autonumbered
"PolicydetailsID"

3rd Table is "Checklist" with a U-Key "ChecklistID"

The Relationship are:
ClientDB to PolicyDetailsID and PolicyDetailsID to ChecklistID.

I designed a form with Tabpages with the following tabs:
Tab1 is a form created from ClientDB
Tab2 is a form created from Policydetails
Tab3 is a form created from Checklist

I was able to synch these page successful by using a TxteventID field
outside of the tabs to synch them but I have one problem.
If someone accidently doesn't enter any policydetails information the
Field linking tab2 and tab 3 results in an ID of Zero(0) which causes
an error on Tab3 that it can't save the information. I need to find a
way to keep someone from entering anything into the Checklist Tab if
the PolicyDetails Tab is on autonumber with blank information.

I need to know how and where to set a condition that
If policydetailsid=0 then the Checklist is invisible.

Please let me know if you need anymore information.

Best Regards
Marco De Julio
Class Act Insurance Services
www.classactinsurance.com
 
T

tina

well, the syncronization and the errors, etc, that you mention aren't
happening to the *tab pages*, they're happening to the subforms that sit on
those tab pages. this is a very important distinction, because when you
write code to manipulate or refer to these objects, you need to have a very
clear picture of whether you're working with a TabPage object, a
SubformControl object, or the Form object within a SubformControl.

i don't have a clear enough picture of how the flow of the form/subforms
progresses, to suggest code to *hide* the tab page holding the Checklist
subform. but you could add code to the Enter event of the Checklist subform
*control*, to lock/unlock the control based on whether there is a value in
the field that links the "policy details" subform (on tab 2, i'm guessing?)
and the "checklist" subform (on tab 3?). the VBA code itself is simple
enough:

Me!ChecklistSubformCONTROLName.Locked = IsNull(SomeField)

if SomeField is Null, the subform control is locked, which means that no
data entry can be done in the subform. if SomeField is not Null, the subform
control is unlocked, which allow data entry in the subform.

the tricky part is referring to "some field" correctly. if you want to check
a control on the main form, the the syntax would be

IsNull(Me!ControlName)

if you want to check a field in another subform, the syntax would be

IsNull(Me!SubformCONTROLName!NameOfFieldInSubform)

hth
 
M

Marco

Oppsss One more question...

Is it possible to have a pop message if the try to click on a field
that is locked. So that I can inform them to complete another page
first?
 
T

tina

well, you could add an If statement to the code i gave you before, as

Me!ChecklistSubformCONTROLName.Locked = IsNull(SomeField)
If Me!ChecklistSubformCONTROLName.Locked Then
MsgBox "Put your message here."
End If

if the first line of code sets Locked to True, then the message box will
immediately pop up. if Locked is set to False, then no message appears.

hth
 
T

tina

and you make it seem sooooo simple...

everything is simple, once you figure out a way to do it <g>
glad it worked for you, Marco :)
 

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