Please Select in form

Dave Titan

Registered User.
Local time
Today, 05:37
Joined
Jan 1, 2002
Messages
69
I've a drop down menu in a form. I'd like users to select an option from this menu before being alowed to leave the form, or better yet before being allowed to enter data they must select from this.

Can some one tell me how? Or perhaps post a link to this question in a previous topic?

Thanks
 
To stop users from leaving the form, on the Before_Update of the form

If isnull(me.NameOfDropdown) then
cancel = True
End if

To stop editing the data before this is filled in, you need initially to disable all of your editable controls except the dropdown then on the After_Update of the Dropdown, check if it is null and if not, re-enable all of the controls. for example

Form_Current (got it right this time Rich;))
if isnull(me.nameofDropdown) then
Call LockAllControls(me)
me.NameOfDropdown.locked = false
else Call EnableAllControls(Me)
end if

DropdownBox After_Update
Form_Current

In a seperate module

Public Sub EnableAllControls(Frm As Form)
Dim ctl As Control
For Each ctl In Frm.Controls

Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Enabled = True
ctl.Locked = False
ctl.BackStyle = 1
End Select

Next ctl
End Sub

Public Sub LockAllControls(Frm As Form)
Dim ctl As Control
For Each ctl In Frm.Controls
Select Case ctl.ControlType

Case acTextBox, acComboBox 'ie Editable Controls
ctl.Enabled = True
ctl.Locked = True
ctl.BackStyle = 0
End Select

Next ctl
End Sub
 
Apologies in the Delay. I can't get the first part of this code to work

Keeps coming up with compile error. This is just for the can't close form option

Any Ideas?
 
What code have you used in your application? Have you replaced NameofDropdown with the actual name of the Combo Control?
 

Users who are viewing this thread

Back
Top Bottom