must select from combobox first

D

deb

acess 2003

I have a subform called fwarranties with a combobox called UnitNo
other fields are changed based on the selection in UnitNo

How can I make the user select from the combobox UnitNo before entering any
other data on the form?

UnitNo must have data first.
 
D

Daryl S

Deb -

You can set the enabled property (or the visible property) to Fasle in
design mode. Then in the AfterUpdate event of the combobox, if a selection
is made then add code to set those values to true.

Me.txtbox.enabled = True or Me.txtbox.visible = True
 
D

Dirk Goldgar

deb said:
acess 2003

I have a subform called fwarranties with a combobox called UnitNo
other fields are changed based on the selection in UnitNo

How can I make the user select from the combobox UnitNo before entering
any
other data on the form?

UnitNo must have data first.


One solution would be to disable all controls on the form (the subform, that
is) until UnitNo is not Null. To do this, you would use the Current event
of the form and the AfterUpdate event of the combo box. Something along the
lines of:

'------ start of example code ------
Private Sub EnableDisableControls()

Dim blnEnabled As Boolean

blnEnabled = Not IsNull(Me.UnitNo)

' If we're going to disable contols, make sure the
' focus is on UnitNo.
If blnEnabled = False Then
Me.UnitNo.SetFocus
End If

' Enable/disable other controls.
Me.SomeControl.Enabled = blnEnabled
Me.SomeOtherControl.Enabled = blnEnabled
' ... and so on ...

End Sub

Private Sub Form_Current()

EnableDisableControls

End Sub

Private Sub UnitNo_AfterUpdate()

EnableDisableControls

End Sub
'------ end of example code ------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top