troubleshooting Question

Function Help

Avatar of thenone
thenone asked on
Visual Basic Classic
4 Comments1 Solution241 ViewsLast Modified:
I'm currently using this function to clean up my table.

Dim DeleteRecord As Boolean, fLoop As Integer
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
conn.CursorLocation = adUseClient
    conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
            & "SERVER=;" _
            & "DATABASE=sites;" _
            & "UID=howard;" _
            & "PWD=password;" _
            & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384

    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    rs.Open "Select * From Business_Split", conn, adOpenKeyset, adLockOptimistic
    With rs
        Do Until .EOF
        DeleteRecord = False
            For fLoop = .Fields(0) To .Fields.Count - 1 'loop among all fields and set DeleteRecord to true if one of them is empty
                If Trim(.Fields(fLoop).Value) = "" Or IsNull(.Fields(fLoop).Value) Then
                    DeleteRecord = True
                    Exit For
                End If
                If InStr(.Fields("keywords"), ",") = 0 Then 'do you mean of there is a double quote?
                    DeleteRecord = True
                End If
                If DeleteRecord Then
                .Delete adAffectCurrent
                End If
    End With

Label2.Caption = "Cleaning Up Records is done"

I have three columns Title,description,keywords,body

What I want to do is the records body is null or blank to delete that record.
if the record description and keywords is blank then get 4 words from the Title and put those four words in keywords.
id title and description is blank then delete that record.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros