hi Mel,
I have a form where i want to select one option or the other, so a user will
have a laptop OR a desktop. i want to be able to only select one of the check
boxes and also lock the check box after the new record has been updated.
Use an Option Group and add two new Check Boxes into it.
But the question here is: How do you store this information?
There are basically three possibilities:
1) Using a Yes/No field, e.g. IsLaptop, then you need only one Check Box
2) Using a Number (Long) field, to store a value mapped to an Option
Group with Option Buttons.
3) Using a lookup table with a Combo Box.
Problems:
Case 1) Your criteria should be IsMobile, then one Check Box makes sense.
Case 2) You need to "hard code" the values in the form design (with your
Option Group), you can't derive any meaning in the database from the value.
Using the terms 'laptop' and 'desktop' indicates that you distinguish
between types of real objects, which makes it an entity in terms of
database design:
http://en.wikipedia.org/wiki/Entity
So you should use the 3th method. Which also provides an easy method to
extend this select, e.g. if in future has an iPad or a Slate, then you
can simply add 'Tablet' as third entry in the lookup table.
The locking is normally done in the form's On Current event:
Private Sub Form_Current()
yourControlName.Locked = True
End Sub
I would place the unlocking into the On Dirty event:
Private Sub Form_Dirty(Cancel As Integer)
yourControlName.Locked = Not Me.NewRecord
End Sub
mfG
--> stefan <--