Unbound list box in a read only form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form to show fields of one record of a query. On this form there are
next_record en previous_record buttons.
On this form i also have a unbound list box based on a query (the same one
as the form itself) showing more than one record of that query at a time.

When i open this form normally i can click on any shown record in the
unbound list box and perform a action.
When i open the form with:

DoCmd.OpenForm "Formname", acNormal, "", "", acReadOnly, acNormal

the form opens read only and i can click on any field except for the unbound
list box.
The list box shows the records but i cannot click on any of them.....


Is there a solution to make the field clickable in Read only mode?

thanks for any idea
 
Instead of opening the form in ready only mode, change the properties for
the specific data fields in your form so that they cannot be edited.

Linda
 
Hi Linda,
Thanks for this idea....this might work...but...
The form i am working on has 10 subforms and each with at least 10 to 20
fields on them. Your solution would imply setting 'read-only' properties on
ALL of them. That's a tremendous work...
Just opening the form the way i described was such a simple and elegant way
to a acheve it with one code line ....except for that list box
so i continu to search....thanks anyway,
Rob
 
Rli said:
Hi Linda,
Thanks for this idea....this might work...but...
The form i am working on has 10 subforms and each with at least 10 to 20
fields on them. Your solution would imply setting 'read-only' properties on
ALL of them. That's a tremendous work...
Just opening the form the way i described was such a simple and elegant way
to a acheve it with one code line ....except for that list box
so i continu to search....thanks anyway,
Rob

:

You could lock all controls on the form in a short loop and then
unlock your listbox. You can use OpenArgs to determine whether to
run the routine when the form opens.

Something like


Dim s As String
Dim ctl As Access.Control
On Error Resume Next
With Me
s = .OpenArgs & vbNullString
If Len(s) > 0 Then
For Each ctl In .Controls
ctl.Locked = True
Next
End If
.List5.Locked = False
End With
On Error GoTo 0
 
Thanks rkc...this looks promissing....
but does this prevent the user to click on for instance a 'delete-record'
button?
i will give it a try
 
Rli said:
Thanks rkc...this looks promissing....
but does this prevent the user to click on for instance a 'delete-record'
button?
i will give it a try

You've probably figured this out by now, but what the loop does is
lock all the controls on the form who's module it is run from. That
includes locking the subform controls which in effect locks the
controls on the subform's form. It's easy enough to unlock a control
on the main form. Unlocking a control on a subform would take some
re-tooling.
 
Back
Top