I am new to access and the commands are all new to me. I wan to use an "if....else" statement to include two conditions. The two conditions are the site must have an cluster name and whether it is a master site?
If the site satisfy both conditions, it will go to the next form. It has to satisfy both conditions to go to the next form. If it does not, an error box will come out.
For the first condition, it is a combo box.
For second condition, it is a Yes/No box.
I will be grateful if someone can help me with this "if...else" statement. Thanks a lot.
I think what you are looking for is a nested IF..ELSE. This might work if you adapt it to your database:
I have a combo box for the form/cluster names and another one for yes/no (too lazy to use a checkbox). The code is accessed by clicking a button:
Private Sub Command14_Click() '* Name of the button to clivk
If Me.comForms = "form2" Then '* I have used the name of the form/cluster
If Me.Combo12 = "Y" Then '* Simple Yes/No
DoCmd.OpenForm "frmUnit" '* Or whatever form you want to open
MsgBox "You must select 'form2' and click Yes"
End If '* combo12
The code will need adapting to your needs, and isn't necessarily the best way to implement it. I would be inclined to use a checkbox with a Yes/No label and raise an event when it's clicked, but that might need a bit more explanation than you want at the moment!
"YourObject.visible = True/False" will also come in handy for what you would like to do. Don't try to change the type of an object, that's a bitch. Instead have two objects and hide the one you don't need.