I have a form and a subform that I want to be able to open in 3 modes: review
existing data without editing, enter new data, edit existing data. I can use
openform from a Switchboard and this works well for the “enter new data” and
“edit existing data modes”.
I am having trouble with the “review existing data without editing” mode,
however. The main form uses two combo boxes to filter the data and show the
subset of data meeting the criteria in the two combo boxes (watershed, and
sampling station within the watershed). These combo boxes seem to be
disabled in the read only mode, and won’t filter the data. It seems read
only affects the unbound controls as well as the bound controls.
Is there a way – when the user selects “review existing data without
editing” – to prevent them from changing or adding data but still allow the
use of the cascading combo boxes on the main form to filter the data?
Thanks for any suggestions you may have,
Chris
strive4peace - 30 Sep 2006 06:46 GMT
Hi Chris,
If you want some control to be able to be edited, you can flip the
"Locked" property of your bound controls...
'~~~~~~~~~~~~~~~~~
Private Function LockUnlock( _
pBooLock As Boolean _
)
'PARAMETERS
'pBooLock = true --> Lock bound controls
'pBooLock = false --> unlock bound controls
Dim ctrl As Control
For Each ctrl In Me.Controls
' MsgBox TypeName(ctrl)
Select Case TypeName(ctrl)
Case "combobox", "textbox"
If Len(ctrl.ControlSource) > 0 Then
ctrl.Locked = pBooLock
End If
End Select
Next ctrl
Set ctrl = Nothing
End Function
'~~~~~~~~~~~~~~
to unlock, assign this to the Click event of your command button:
=LockUnlock(false)
to lock...
=LockUnlock(true)
you can expand
Case "combobox", "textbox"
to include the other control types you want to check...
Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
> I have a form and a subform that I want to be able to open in 3 modes: review
> existing data without editing, enter new data, edit existing data. I can use
[quoted text clipped - 14 lines]
> Thanks for any suggestions you may have,
> Chris