Multiple combo boxes or list boxes

G

Guest

I am having difficulty with multiple combo boxes not linking. They come from separate table, but I have a subform that communicates to both tables. Just having trouble writing the code
 
J

John Vinson

I am having difficulty with multiple combo boxes not linking. They come from separate table, but I have a subform that communicates to both tables. Just having trouble writing the code

"Doctor, I don't feel good. What should I do?"

Please post your code and some description of the combo boxes and what
you're trying to do with them. There is simply no information in your
question that would enable anyone to answer.
 
G

Guest

"Having a bad hair day today, huh!!

Combo2 generates data in the subform. But I need combo3 and combo4 to be able to do the same thing Onchange if I choose to select from those instead. Just a matter of choices from different tables

Private Sub Combo2_AfterUpdate(
' Find the record that matches the control
Dim rs As Objec

Set rs = Me.Recordset.Clon
rs.FindFirst "[Error] = " & Str(Me![Combo2]
Me.Bookmark = rs.Bookmar
End Sub
 
J

John Vinson

"Having a bad hair day today, huh!!"

No. *You're* being unreasonable. Remember, YOU can see your database.
I cannot, and my clairvoyance has been pretty flaky lately!

I do not have any idea what fields you want to search, what the
Rowsource of any of these combo boxes might be, what their control
source might be, what you mean by "generates data", what the Onchange
event has to do with anything... or even what specific problem you are
having, since you have not posted that information.
Combo2 generates data in the subform. But I need combo3 and combo4 to be able to do the same thing Onchange if I choose to select from those instead. Just a matter of choices from different tables.

Private Sub Combo2_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Error] = " & Str(Me![Combo2])
Me.Bookmark = rs.Bookmark
End Sub

If you put similar code on Combo3 and Combo4, what happens? What error
are you getting, or what is the undesired result?
 
L

Lynn Trapp

Vee,
I'm afraid I'm just about as puzzled as John is. It would be helpful if you
would answer his question:

If you put similar code on Combo3 and Combo4, what happens? What error
are you getting, or what is the undesired result?

I might also mention that you may not get much help from other people if you
tell John, "...I prefer you (John Vinson) did not respond...." John is one
of the most helpful and knowledgeable people in this, or any other,
newsgroup. He is an excellent forms developer and you shouldn't turn your
ear to what he has to say.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Vee said:
Let me try this again, but I prefer you (John Vinson) did not respond. I
have a form with Combo1 linked to the subform (separate tables). I would
like to be able to include another combo (from differ table) to pull from
the subform as well. In other words, I want to see everything in the
subform for whatever is specified in Combo1 and Combo2. Just not sure how
the code should read for Combo2. The row and control source for Combo2
selecting from the table itself.
Private Sub Combo1_AfterUpdate
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Error] = " & Str(Me![Combo1])
Me.Bookmark = rs.Bookmark
End Sub
 
S

Sylvain Lafontaine

Hum, looks to me as someone trying to use the AND operator with the ADO
version of FindFirst. Unlike the DAO version of FindFirst, this is not
possible with ADO.

He should take a look at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnima00/html/find.asp

Also, replacing "Dim rs As Object" with "Dim rs As ADODB.Recordset" or ""Dim
rs As DAO.Recordset"" (with or without the new operator) should be better.
(The new operator give the option of using early binding instead of late
binding.)

S. L.

Lynn Trapp said:
Vee,
I'm afraid I'm just about as puzzled as John is. It would be helpful if you
would answer his question:

If you put similar code on Combo3 and Combo4, what happens? What error
are you getting, or what is the undesired result?

I might also mention that you may not get much help from other people if you
tell John, "...I prefer you (John Vinson) did not respond...." John is one
of the most helpful and knowledgeable people in this, or any other,
newsgroup. He is an excellent forms developer and you shouldn't turn your
ear to what he has to say.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Vee said:
Let me try this again, but I prefer you (John Vinson) did not respond.
I
have a form with Combo1 linked to the subform (separate tables). I would
like to be able to include another combo (from differ table) to pull from
the subform as well. In other words, I want to see everything in the
subform for whatever is specified in Combo1 and Combo2. Just not sure how
the code should read for Combo2. The row and control source for Combo2
selecting from the table itself.
Private Sub Combo1_AfterUpdate
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Error] = " & Str(Me![Combo1])
Me.Bookmark = rs.Bookmark
End Sub
 
S

Sylvain Lafontaine

See also http://experts.about.com/q/1440/604158.htm for another option.

S. L.

Sylvain Lafontaine said:
Hum, looks to me as someone trying to use the AND operator with the ADO
version of FindFirst. Unlike the DAO version of FindFirst, this is not
possible with ADO.

He should take a look at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnima00/html/find.asp

Also, replacing "Dim rs As Object" with "Dim rs As ADODB.Recordset" or ""Dim
rs As DAO.Recordset"" (with or without the new operator) should be better.
(The new operator give the option of using early binding instead of late
binding.)

S. L.

Lynn Trapp said:
Vee,
I'm afraid I'm just about as puzzled as John is. It would be helpful if you
would answer his question:

If you put similar code on Combo3 and Combo4, what happens? What error
are you getting, or what is the undesired result?

I might also mention that you may not get much help from other people if you
tell John, "...I prefer you (John Vinson) did not respond...." John is one
of the most helpful and knowledgeable people in this, or any other,
newsgroup. He is an excellent forms developer and you shouldn't turn your
ear to what he has to say.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Vee said:
Let me try this again, but I prefer you (John Vinson) did not respond.
I
have a form with Combo1 linked to the subform (separate tables). I would
like to be able to include another combo (from differ table) to pull from
the subform as well. In other words, I want to see everything in the
subform for whatever is specified in Combo1 and Combo2. Just not sure how
the code should read for Combo2. The row and control source for Combo2
selecting from the table itself.
Private Sub Combo1_AfterUpdate
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Error] = " & Str(Me![Combo1])
Me.Bookmark = rs.Bookmark
End Sub
 
G

Guest

It's not a matter of turning away. But there is a way to communicate with people w/o being rude. Perhaps he was having a bad day - but I did not need to know that. There error code that I was getting was Error 13 - I specified that after I sent the first one in separately
 
M

Michel Walsh

Hi,


It is not very clear what you want to do.


If you want to display, in the subform all records where the value
of field f1 is the one actually displayed either in combo1, either combo2,
either in combo3, I would then:

- remove any parent-child link properties between the main form and
the subform. At that point, the subform should no react anymore from
anything occurring in the main form.

- in the after update event of each combo box, I will call the
following subroutine:


Public Sub SynchMySubForm( )

With Me("SubformControlNameHere").Form ' the 3 following lines start
with a dot
.FIlterOn = false
.Filter = "f1 IN(" & Me.Combo1 & ", " & Me.Combo2 & ", " &
Me.Combo3 )
.FilterOn = True
End With


End Sub



If your field f1 is not numerical, but alphanumerical, the filter line
should be:

.Filter = "f1 IN('" & Me.Combo1 & "', '" & Me.Combo2 & "', '" &
Me.Combo3 & "'" )



where I assumed there is no ' in the "name" supplied by the combo box.



So, the logic is to filter the records displayed in the subform, after each
modification in any of the combo box.


That is assuming that this is what you want to do.



Vanderghast, Access MVP





Vee said:
It's not a matter of turning away. But there is a way to communicate with
people w/o being rude. Perhaps he was having a bad day - but I did not need
to know that. There error code that I was getting was Error 13 - I
specified that after I sent the first one in separately.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top