Form / Subform question from Newbie

  • Thread starter Thread starter moggie
  • Start date Start date
M

moggie

Hi all,

I'd appreciate any information on how to create dynamic
subforms. Here is my situation:

I have a contract table with a drop down list for type. In
my main form I'd like the user to be able to select one of
four types and based on part of the string decide which
form to open.

IE: For a Contract Type of 'Inhouse Development'
or 'Inhouse Production' open the subform Inhouse Details
if it's anything else open subform Other.

Currently I have a button to open a new form, and I'm
trying to muddle my way through an event procedure. Am I
trying this the right way?

Thanks in advance,
Moggie
 
Moggie,

Are you talking about subforms (meaning they are placed on a main/parent
form) or do you mean separate forms like more than one window? It sounds
like you mean a separate form. So, here's an example of what to do...

If Me.ContractType = "Inhouse Development" or _
Me.ContractType = 'Inhouse Production' then
DoCmd.OpenForm "Name of Form", ....
Else
DoCmd.OpenForm "Other", ....
End If

Hope this helps!

Diana Criscione
 
Hi Diana,

I guess I should have said that I'd like the Subform to
display not open. I have currently got my two subforms on
a tab control one on each tab. Is it possible when a user
selects an option it can display one and hide the other?
Am I making this more difficult than needs be?

Thanks for any help,

Moggie
 
Moggie,

No, you're not making it more difficult. In fact, I think using subforms on
tab controls is more user friendly. So, if the two subforms you have are
"inhouse" stuff and "other" then you are wanting to display the correct one?
If so, change the code I suggested before by replacing the "DoCmd.OpenForm"
with...
Me.TabWhatever.SetFocus
As long as the subforms are actually on the tabs, then just setting focus on
the correct tab will "hide" the other.

Let me know how it works out!

Diana
 
Back
Top