Solved

avoid exporting duplicate strings

Posted on 2014-11-27
7
75 Views
Last Modified: 2014-11-27
In the following project, I am modifying websites from a text file in an MSFlexGrid.  What is needed is a way to check whether the newly added entries are already duplicated before exporting them to the text file again.  

How can I put a msgbox or test in place to avoid duplication?

Also, how can I sort the sites in alphabetical order?
CB.zip
0
Comment
Question by:al4629740
  • 4
  • 3
7 Comments
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40469509
When you say alphabetical order are you talking just about what you see in the grid? If so that is probably not too hard, but if you are also talking about the output file that's not possible unless the output file consists of only the records that start with "^" and not records like "ALLOW_DROPBOX_r05-02-2013".
0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40469535
To avoid duplication, replace the current ValidWebsite  function with this one.
Private Function ValidWebsite() As Boolean
Dim intPos As Integer
Dim lngIndex As Long

If Not txtEdit.Visible Then
    ValidWebsite = True
    Exit Function
End If

intPos = InStrRev(txtEdit.Text, ".")
' The "Len" portion of the following makes sure that there's
' something following the dot
If intPos = 0 Or intPos = Len(txtEdit.Text) Then
    MsgBox "The website name must have a domain", vbExclamation + vbOKOnly, "Missing Domain Name"
    txtEdit.SetFocus
    Exit Function
End If

For lngIndex = 0 To MSFlexGrid1.Rows - 1
    If UCase(MSFlexGrid1.TextMatrix(lngIndex, 0)) = UCase(txtEdit.Text) Then
        MsgBox "The website name '" & txtEdit.Text & "' already exists", vbExclamation + vbOKOnly, "Missing Domain Name"
        txtEdit.SetFocus
        Exit Function
   End If
Next

ValidWebsite = True
End Function

Open in new window

0
 

Author Comment

by:al4629740
ID: 40469544
alphabetical in the grid only
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 45

Expert Comment

by:Martin Liss
ID: 40469546
Phew! It's still going to be tricky but I'll give it a try.
0
 

Author Comment

by:al4629740
ID: 40469566
I'll open it in another question
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40469570
Thanks, I appreciate that.
0
 

Author Comment

by:al4629740
ID: 40469573
Nope, I appreciate your help
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now