Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Combo Box Display

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
O Wilson - 01 Mar 2006 01:47 GMT
Hello,

I have two related combo boxes named "cboIssuedTo" and "cboContact", both
pulling data from table "Contacts".  As of now, I have only been able to
poplate cboContact with one item based on ContactID.  I would like to
populate cboContact with multiple names, from the same company.  My attempts
pretty much look like this:

Private Sub cboIssuedTo_AfterUpdate()

Me.cboContact.RowSource = "SELECT FirstName & "" "" & LastName FROM" & _
  " Contacts WHERE CompanyName = " & Me.cboIssuedTo & _
  " ORDER BY CompanyName"
Me.cboContact = Me.cboContact.ItemData(0)

The above does not put any data in cboContact. Any help wold be greatly
appreciated.

TIA
Signature

O Wilson

Rick Brandt - 01 Mar 2006 01:55 GMT
> Hello,
>
[quoted text clipped - 15 lines]
>
> TIA

You might need to issue a Requery on the ComboBox after changing its
RowSource...

Me.cboContact.Requery

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

John Spencer - 01 Mar 2006 13:58 GMT
I suspect a problem in the SQL you are building.  I think that companyName
is text.  If so, try

Me.cboContact.RowSource = "SELECT FirstName & "" "" & LastName FROM" & _
  " Contacts WHERE CompanyName = " & Chr(34) & Me.cboIssuedTo & Chr(34) & _
  " ORDER BY CompanyName"

I found that setting the row source to an invalid SQL statement fails
silently and simply returns no matches.  During development I often use a
text variable to build the SQL statement so I use debug.print to examine it
for syntax.

Dim strSource as String

StrSource = "SELECT FirstName & "" "" & LastName FROM" & _
  " Contacts WHERE CompanyName = " & Chr(34) & Me.cboIssuedTo & Chr(34) & _
  " ORDER BY CompanyName"

Debug.Print strSource
Me.CboContact.RowSource = strSource

> Hello,
>
[quoted text clipped - 16 lines]
>
> TIA
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.