OpenForm method

maxmangion

AWF VIP
Local time
Today, 08:01
Joined
Feb 26, 2003
Messages
2,805
Hi,

I have created an unbound form, which has 4 combos and 4 command buttons and when the form is opened all these have their enabled property set to false. Then i have another combo box which has 4 values in it, and when a value is selected, a combo and its associated command button are enabled. Eventually i select a value from the new enabled combo , click the command button and a new form will open up.

When i get back to the form and the focus is set on the main combo ... all the other four combos and their respective buttons get disabled again. Now my problem is that if i select again the combo which i had selected previously, as soon as that combo get enabled and select a value, if i click the button instead of opening the form as intended, i am getting an error stating the OpenForm method was cancelled.

Any ideas why this happens since the first time it work fine ?

The following is the code which is associated with the button:

DoCmd.OpenForm "frmName"

The following is the code which i have on the main combo on it OnLostFocus event:

Code:
Dim frm As FormDim ctl As Control
Set frm = Screen.ActiveForm
For each ctl in frm.ControlsIf (typeof ctl is ComboBox or typeof ctl is TextBox) and ctl.Name <> "cboSearchType" Then 'cboSearchType is the main combo which never gets disabled
ctl.Enabled = False
End If
Next

Also the following is the code which i have on the afterupdate event of the main combo:

Code:
Dim choice As String
Select Case choice
Case "cboCombo1"
me.cboCombo1.Enabled = True
me.cmdButton1.Enabled = True

the same code goes for the other combos

End Select

Any ideas why i am getting that message

P.s. when the command button is clicked and the new form opens up, it opens based on the value selected in that combo, so in the query of that form i placed the following in the criteria: [Forms]![frmSearch]![cboName]

Thanks
 
Last edited:

Users who are viewing this thread

Back
Top Bottom