Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fields to a listbox that doesn't repeat! Anyone?

Status
Not open for further replies.

chassid

MIS
Aug 27, 2000
58
US
All,

I have an asp page that loads fields from an ACCESS database into a listbox. I would like values not to repeat. Meaning instead of getting 50 southeast and 100 Northwest they would only get on southeast and one Northwest.

I have tried this:
sqlSrch.Open "Select DISTINCT From act1 where id=" &_
but the command DISTINCT only seems to work with sql databases and not with ACCESS.

Does anyone know how to do this working with an ACCESS database?

Any help will be greatly appreciated!

Daniel [sig][/sig]
 
If this SQL statement is what you use then there's one thing missing : name of a field you want to pull out from Access. You'd write it like this:
"Select distinct [red]field_name[/red] from act1 where ..."


 
guestg,

I tried that but it still didn't work!!! This is the whole select statement:

If Len(Request.QueryString(&quot;id&quot;)) <> 0 Then
sqlSrch.Open &quot;Select distinct chapter From act1 where id=&quot; &_
Request.QueryString(&quot;chapter&quot;), dbGlobalWeb, 0, 1
If not sqlSrch.EOF Then
sqlSrch.MoveFirst

Does you or anyone know how to fix this so that values won't repeat?

Daniel
[sig][/sig]
 
From your post it's not clear whether you've fixed problems with duplicates or not.
As for code you've posted, there's a problem, that could give you a problem :

If Len(Request.QueryString([red]&quot;id&quot;[/red])) <> 0 Then
sqlSrch.Open &quot;Select distinct chapter From act1 where id=&quot; &_
Request.QueryString([red]&quot;chapter&quot;[/red]), dbGlobalWeb, 0, 1

If I'm not mistaken, you check to see if request.QueryString(&quot;id&quot;) has some value, and if it does, for some reason you pass request.QueryString([red]&quot;chapter&quot;[/red]) to your query :

where id=&quot; &_
Request.QueryString([red]&quot;chapter&quot;[/red])


Of course, I don't know everything about your task, but I think, that request.QueryString([red]&quot;id&quot;[/red]) is more likely to be passed to the query.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top