Go Back   DeveloperBarn Forums > Databases > Microsoft Access

Sponsored Links

Discuss "Remove Duplicates From a String" in the Microsoft Access forum.

Microsoft Access - Microsoft Access is a database for small to medium applications. Learn tips and tricks and best database practices here.


Closed Thread « Previous Thread | Next Thread »  
 
LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1  
Old May 8th, 2008, 07:16 AM
AOG123's Avatar
Lightning Master

 
Join Date: Mar 2008
Location: Fortress Of Solitude
Posts: 93
Thanks: 6
Thanked 23 Times in 18 Posts
Rep Power: 1
AOG123 is on a distinguished road

Awards Showcase
Microsoft Access 
Total Awards: 1

Default Remove Duplicates From a String

Say i have the following in a field

<DeveloperBarn, Forums, Forums>

How can i remove the duplicate words in a query?

Thanks AOG
__________________
If i helped you, make me famous by clicking the

Last edited by AOG123; May 8th, 2008 at 07:35 AM.
Sponsored Links
  #2  
Old May 8th, 2008, 10:25 AM
sbenj69's Avatar
Moderator

 
Join Date: Mar 2008
Posts: 84
Thanks: 20
Thanked 24 Times in 19 Posts
Rep Power: 1
sbenj69 is on a distinguished road

Awards Showcase
Microsoft Windows Microsoft Access 
Total Awards: 2

Default

This will need to be done in vba:

Code:
Dim pos1 as integer
Dim pos2 as integer
Dim newstring as string

pos1=1
pos2=0
newstring=""


Do while instr(pos1,me.yourfield, ",") > 0

Pos2=instr(pos1,me.yourfield, ",")

if instr(pos1,newstring, mid(me.yourfield, pos1, pos2 - pos1))=0
newstring=newstring & mid(me.yourfield, pos1, pos2 - pos1) &", "
End If

Pos1 = Pos2+1
Pos2 = 0

Loop

Me.yourfield = newstring

Last edited by sbenj69; May 8th, 2008 at 11:20 AM.
Closed Thread

  DeveloperBarn Forums > Databases > Microsoft Access

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
remove comma todd2006 JavaScript Programming 12 May 7th, 2008 10:55 AM

LinkBacks (?)
LinkBack to this Thread: http://www.developerbarn.com/microsoft-access/175-remove-duplicates-string.html
Posted By For Type Date
Remove duplicate words from a string - ASP Free This thread Refback May 8th, 2008 11:14 AM


All times are GMT -4. The time now is 04:48 PM.



Content Relevant URLs by vBSEO 3.2.0