Multiple criteria...

  • Thread starter Thread starter Cerberus
  • Start date Start date
C

Cerberus

I’m relatively new to programming so forgive me if I have trouble conveying
my question properly. Is it possible to show a new UserForm based on meeting
three criteria? In my case, I have multiple door sizes that are available
but only when a certain criterion have been met, i.e. "25belt-full swing-flip
up" has multiple opening sizes but a "48belt-full swing-flip up" only has one
size.

Now I want to make a UserForm "pop up" when the conditions are right, that
have the opening sizes so I don't have too many grayed out selections when
choices are not applicable. So in the example above I would think I need
something like (and this is where I have the lack of knowledge):

If Start.Option25belt.Value = True And _
Door.OptionFullSwing.Value = True And _
Door.OptionFlipUp.Value = True Then
Opening.Show
End If

I'm sure that is not even close to being correct but I hope it helps give a
understanding of what I'm looking for. Thank you in advance for anny
assistance.
 
With Access VBA, you can use:

DoCmd.OpenForm "Opening", WindowMode := acDialog


which will open the form Opeming in a dialog mode, forcing the user to
interract with the form before the VBA code continue its execution with the
line following this one.

DoCmd.OpenForm has many possible optional parameters. Using the name
parameter syntax, we can skip to the parameter we want. Here, WindowMode:=
skiped over many of the optional parameters to jump to the one called
WindowMode. Not only can you skip over the named parameters, but use them in
any order:


Docmd.OpenForm WindowMode := acDialog, FormName := "Opening"

If you only want to display a message, you can use:


MsgBox "You have to .. ", Title:= "Invalid Input",
Buttons:=vbOKOnly+vbCritical


where the Buttons arguments does not only specify which buttons are to be
displayed (here, only the OK button), but also, the icon to use (here, the
critical icon). You don't use the DoCmd.OpenForm with MsgBox, since MsgBox
creates the 'form' on the fly for you, rather than using an already made
form.




Vanderghast, Access MVP
 
I would suggest a better way that will keep it down to one form, but without
the greyed out controls.

Use the Visible Property of each control where you enter sizes. You can use
the form's Current event to determine which controls to make visible or not
visible.
 
Back
Top