mutiple Combobox 's problem

  • Thread starter Thread starter Sammy
  • Start date Start date
S

Sammy

I have a continuous form with 2 different records. Each
one could have different number of comboboxes. What I am
trying to do is count each combobox for each record listed
and if any of them are null and enabled for say record1
then do nothing else if all the comboboxes of record1 is
not null and enabled do something.

Does anyone have a quick fix for this?

Thanks in advance
 
I have a continuous form with 2 different records. Each
one could have different number of comboboxes.

Ummm... No. It couldn't. Or perhaps I'm misunderstanding what you're
describing!

Tables don't contain comboboxes and don't have variable numbers of
fields from record to record. A Form or a Combo is *JUST A TOOL* for
entering data into a Table; what's the structure of your table?
What I am
trying to do is count each combobox for each record listed
and if any of them are null and enabled for say record1
then do nothing else if all the comboboxes of record1 is
not null and enabled do something.

Does anyone have a quick fix for this?

Again... you can't "count comboboxes". You can count values in a table
field, but a form will have a fixed number of combo boxes.

Please step back a bit, describe your table, and describe what (in a
business sense) you're trying to accomplish. I'm sure it's possible
but until I have a clearer understanding of the problem I'm not sure
what to advise!

John W. Vinson[MVP]
(no longer chatting for now)
 
You are right each record would have an equal amount of
combo boxes. However, each time you open the form it have
a different depending on the variable you select to open
the form. Let me consider just one record and can
recreate for the other. What I am thinking is create a
hidden textbox. Some how count the number of combo boxes
are on the form. For each combo box enabled and is not
null have it add a number inside the text box. If the
number equals the number of combo boxes then have it do
something if not then have it do something else. Would
this be a better scenario? If so how do I do the loop?

Thanks for any feedback
 
You are right each record would have an equal amount of
combo boxes. However, each time you open the form it have
a different depending on the variable you select to open
the form. Let me consider just one record and can
recreate for the other. What I am thinking is create a
hidden textbox. Some how count the number of combo boxes
are on the form. For each combo box enabled and is not
null have it add a number inside the text box. If the
number equals the number of combo boxes then have it do
something if not then have it do something else. Would
this be a better scenario? If so how do I do the loop?

I'm still not understanding the situation.

What determines whether a combo box is enabled (visible??) or not?
What are the Control Source properties of these combos? What data
exists in the table? What is the significance of this variable, and
how is it specified?

I'll be out of town tomorrow - if nobody else jumps in, please repost
so the other MVP's won't take this as an answered thread... because
I'm still confused!

John W. Vinson[MVP]
(no longer chatting for now)
 
Ok here's the deal. I have a form with a subform. The
subform list task to be accomplished by individuals.
Their can be one or two people. Each one can have the
same task or different task. Each task is then selected
which then pops up another form related to that task
called subtask. If the first person is required to
complete that task then the combo boxes from the pop up
form are enabled if not then they are not enabled. Now
the number of these subtasks(comboboxes) can can be
different for each task selected. This all works fine.
My problem is I need to figure out a way to count each of
these combo boxes on the pop up form. Then check to see
if each one is enabled and not null. If each one meets
this requirement then it will run a query to update the
subform on the main. If not then it will still store the
on the subtask but not update the subform. they will
cause the inspector to come back to complete this task
during evaluation.

I hope this is not getting too confusing. All I need to
do is figure a way to count the number of a particular
comboxes to check to see if it meets my requirement if so
do something if not then do something else. This is on a
continuous form. I looked at the help Count property but
it counts all the controls ie lables, textboxes,
comboboxes etc.

thanks for any help or suggestions
 
Never mind I figured it out.

DDNS is a variable to the main form subform

Dim i, j, m, n As Integer

' Cycle through the form's controls,
' testing for text and combo boxes,
DoCmd.GoToRecord , , acFirst
m = 0
n = 0
For j = 0 To Me.RecordsetClone.RecordCount - 1

For i = 0 To Me.Count - 1
If TypeOf Me(i) Is ComboBox Then
If Me(i).Visible = True Then
If Me(i).Name = "PSS1" Then
'If combo box exist add 1
m = m + 1
If IsNull(Me!PSS1) = False Then
' If combo box has any text add 1
n = n + 1
End If
End If
End If
End If
Next i

On Error Resume Next
DoCmd.GoToRecord , , acNext
Next j
'if the values of n and m don't equal then skip and
make subform value null
If n <> m Then
DNDS![PSS1].Value = Null
' else continue
Else
 
Back
Top