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 / Forms Programming / April 2005

Tip: Looking for answers? Try searching our database.

select except a particular value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J Cole - 30 Apr 2005 18:52 GMT
Hi, I have two combo boxes and two text boxes on a form. When the form loads,
the first combo box gets pre-filled with the column values. The user selects
a particular value on the first combo box and adds comments in a particular
text box.
Now, I want the second combo box to get filled with the column values minus
the value already chosen on the first combo box. How do I incorporate this?
In particular, what SQL query will yield the desired result for the second
combo box in question?

Any inputs will be much appreciated.

TIA,
cole
Ken Snell [MVP] - 30 Apr 2005 19:00 GMT
This article tells you how to tie the two combo boxes together:
http://www.mvps.org/access/forms/frm0028.htm
Signature


       Ken Snell
<MS ACCESS MVP>

> Hi, I have two combo boxes and two text boxes on a form. When the form
> loads,
[quoted text clipped - 14 lines]
> TIA,
> cole
J Cole - 30 Apr 2005 20:27 GMT
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
 
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.