> Hi, I have two combo boxes and two text boxes on a form. When the form
> loads,
[quoted text clipped - 14 lines]
> TIA,
> cole
hi Ken,
Thanks for your response. I did try to follow as directed in the link that
you mentioned. But, my problem is not solved.
Let me try to be clear in what I'm looking for:
Say I have a table 'Category' with data as below:
CategotyID CategoryName
------------ ----------------
1 vb
2 C
3 sql server
4 office
Now, say I have two combo boxes. cbOne and cbTwo.
Now, when the form loads, I ahve all the category Id's prefilled in cbOne.
When the user selects a value for cbOne (say 2) then,
I want only (1,3, and 4) to be listed in cbTwo.
I tried to do this:
1. Set to rowSource for cbOne to Category table - CategoryID
2. Added the afterUpdate event for cbOne
Private Sub cbOne_AfterUpdate()
Dim strSQL As String
strSQL = "select " & Me.cbOne
strSQL = strSQL & " from Category"
Me.cbTwo.RowSourceType = "Table/Query"
Me.cbTwo.RowSource = strSQL
Me.cbOne.Requery
End Sub
3. Left the RowSource for cbTwo blank.
What this does is list only that which is selected in cbOne (i.e. 2) and not
what I'm expecting (1,3, and 4).
Am I missing something?
thanks,
cole
> This article tells you how to tie the two combo boxes together:
> http://www.mvps.org/access/forms/frm0028.htm
[quoted text clipped - 16 lines]
> > TIA,
> > cole
Douglas J. Steele - 30 Apr 2005 21:34 GMT
You'd want:
strSQL = "select Id from Category"
strSQL = strSQL & "where Id <> " & Me.cboOne

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> hi Ken,
>
[quoted text clipped - 61 lines]
>> > TIA,
>> > cole
Jeff Conrad - 30 Apr 2005 21:56 GMT
Slight modification to Doug's syntax. A space is needed before the Where clause.
Try:
strSQL = "Select CategoryID from Category"
strSQL = strSQL & " Where CategoryId <> " & Me.cbOne

Signature
Jeff Conrad
Access Junkie
Bend, Oregon
> You'd want:
>
> strSQL = "select Id from Category"
> strSQL = strSQL & "where Id <> " & Me.cboOne
Douglas J. Steele - 30 Apr 2005 22:24 GMT
Good catch, Jeff.
I SWEAR I had a space after Category when I first typed it, but I went back
to pretty it up...

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> Slight modification to Doug's syntax. A space is needed before the Where
> clause.
[quoted text clipped - 7 lines]
>> strSQL = "select Id from Category"
>> strSQL = strSQL & "where Id <> " & Me.cboOne
Jeff Conrad - 01 May 2005 00:14 GMT
> Good catch, Jeff.
>
> I SWEAR I had a space after Category when I first typed it, but I went back
> to pretty it up...
No problem.
:-)

Signature
Jeff Conrad
Access Junkie
Bend, Oregon
Dan Artuso - 30 Apr 2005 21:47 GMT
Hi,
You would want something like this:
Dim strSQL As String
strSQL = "select CategoryId, CategoryName From Category"
strSQL = strSQL & " WHERE CategoryId <> " & Me.cbOne
Me.cbTwo.RowSourceType = "Table/Query"
Me.cbTwo.RowSource = strSQL
Me.cbOne.Requery
--
HTH
Dan Artuso, Access MVP
> hi Ken,
>
[quoted text clipped - 64 lines]
> > > TIA,
> > > cole
J Cole - 30 Apr 2005 23:36 GMT
Thank you all for responding. It worked. It was a simple SQL query! I will
endeavour to spending more time in solving things like these before posting.
Appreciate your support.
thanks,
cole
> Hi,
> You would want something like this:
[quoted text clipped - 77 lines]
> > > > TIA,
> > > > cole