A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Combo Box Display



 
 
Thread Tools Display Modes
  #1  
Old March 1st, 2006, 01:47 AM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default Combo Box Display

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
--
O Wilson
  #2  
Old March 1st, 2006, 01:55 AM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default Combo Box Display

O Wilson wrote:
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


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

Me.cboContact.Requery

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


  #3  
Old March 1st, 2006, 01:58 PM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default Combo Box Display

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


"O Wilson" wrote in message
...
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
--
O Wilson



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to limit contents in combo box on subform Bob A. Using Forms 4 February 25th, 2006 09:00 PM
Displaying Additional Columns in Access Form Roxanne General Discussion 3 September 20th, 2005 06:50 PM
Display 1+ column in combo box Mrs. Kim Using Forms 1 August 5th, 2005 12:26 AM
DISPLAY 2 COLUMNS IN A COMBO BOX Mrs. Kim Using Forms 2 August 1st, 2005 03:26 AM
Design questions Bruce Database Design 15 June 19th, 2004 12:12 AM


All times are GMT +1. The time now is 10:24 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.