Developer Solutions db 2000 - limiting contents

  • Thread starter Thread starter Barbara
  • Start date Start date
B

Barbara

I have used the form example in Developers Solution 2000
that limits the contents of one list based on the value
selected in another and the find a record based on a
value you select from a list. The two combo boxes are in
the header. The first combo box limits the second combo
and then the record in the detail section is determined
by the selection in the second combo. This works
great... once. If you want to make a second selection
from the category combo box it won't work because the
records in the detail section are filtered. How do I
make the form work each time a category is selected?
 
Hi,
It's hard to say without seeing any of your code.
I took a look at the 'find a record based on a value you select from a list'
sample and it does exactly what you seem to want, at least in the
Acc 97 sample it does.

You can make as many selections as you like (from either combo) and the form always updates.
Are you using the code from that sample?
 
Thanks for replying. I am using the code from the 2000
Solution database, I don't have the '97 one. The 2 combo
boxes are cbodbCatSelect and cboLocationSelect, in the
header of the form. The category box limits the contents
of the address box and the address box applies a filter
to display the correct record. There is also a module to
enable the controls. Here is the code:



Private Sub cboDbCatSelect_AfterUpdate()
' Enable and requery cboLoctionSelect combo box.
' Disable controls in detail section.

Me!cboLocationSelect.Enabled = True
Me!cboLocationSelect.Requery
EnableControls Me, acDetail, False

End Sub

Private Sub cboLocationSelect_AfterUpdate()
' Find record for location selected in cboLocationSelect
combo box.
' Enable controls in detail section and disable
AddrID text box.
' Go to cboLocationSelect combo box.

DoCmd.ApplyFilter , "AddrID = Forms!frmEditLocation!
cboLocationSelect"
EnableControls Me, acDetail, True
Me!AddrID.Enabled = False
Me!BusName.SetFocus


End Sub

Private Sub Form_AfterUpdate()

' Requery cboLocationSelect combo box.
Me!cboLocationSelect.Requery

End Sub

Private Sub Form_Current()

Me!cboLocationSelect.Requery

End Sub


Module:

Function EnableControls(frm As Form, intSection As
Integer, intState As Boolean) As Boolean

' Enable or disable controls in specified section of
form.
' Use the Form object, section constant, and state
arguments
' passed to the EnableControls procedure.

Dim ctl As Control

' Set intState for all controls in specified section.
For Each ctl In frm.Controls
If ctl.Section = intSection Then
On Error Resume Next
ctl.Enabled = intState

Err = 0
End If
Next ctl

EnableControls = True
End Function


As I said, this works great once but there is no code to
remove the filter, show all records, or in some other way
reset the form so additional category selections can be
made. I did decide I could add a command button that
opens and closes the form (causing it to reset) with the
text "edit additional records", but thats a pretty funky
way to correct the problem! Your input is appreciated.
Barbara
-----Original Message-----
Hi,
It's hard to say without seeing any of your code.
I took a look at the 'find a record based on a value you select from a list'
sample and it does exactly what you seem to want, at least in the
Acc 97 sample it does.

You can make as many selections as you like (from either
combo) and the form always updates.
Are you using the code from that sample?
--
HTH
Dan Artuso, Access MVP


"Barbara" <[email protected]> wrote in
message news:[email protected]...
 
Back
Top