Extra_Cover
Registered User.
- Local time
- Today, 12:22
- Joined
- Oct 21, 2008
- Messages
- 71
Hi All - New here.
You look like a knowledgeable lot and I wonder if anyone has a better way of solving a problem I have?
I can Join a table imported from a telephone management system to a table containing customer information by the 'phone number field. However the customer information table contains duplicate telephone numbers (each customer has a code that starts with a T and a G - it's a long story...). It doesn't matter which code is used.
The code I have used follows, it basically read all the records in to an array and then loops through a replica record set, deletes any occurrences of the number and adds the array value back. While the code works I'm sure there is a cleaner (and faster - their are over 8000 customers to trawl through) way to do this.
' Next Remove any duplicate Numbers
'Set rs = CurrentDb.OpenRecordset("SELECT * FROM TblNoSpace")
'Set rs1 = CurrentDb.OpenRecordset("SELECT * FROM TblNoSpaceFinal")
'With rs
' rs.MoveFirst
' x = 1
' Do Until rs.EOF
' custcode(x) = rs.Fields("lcus_code")
' custname(x) = rs.Fields("lcus_name")
' custphone(x) = rs.Fields("lcus_phone")
' rs.MoveNext
' x = x + 1
' Loop
'End With
'MsgBox ("All REcords copied to Array " & x)
'For y = 1 To x
'With rs1
' rs1.MoveFirst
'
' Do Until rs1.EOF
' If rs1.Fields("lcus_phone") = custphone Then
' rs1.Delete
' End If
' rs1.MoveNext
'
' Loop
' Add Record Back In
' rs1.AddNew
' rs1.Fields("lcus_code") = custcode
' rs1.Fields("lcus_name") = custname
' rs1.Fields("lcus_phone") = custphone
' rs1.Update
' End With
' Me.FrmRecCount1 = y
'Next y
'rs.Close
'rs1.Close
'Set rs = Nothing
'Set rs1 = Nothing
You look like a knowledgeable lot and I wonder if anyone has a better way of solving a problem I have?
I can Join a table imported from a telephone management system to a table containing customer information by the 'phone number field. However the customer information table contains duplicate telephone numbers (each customer has a code that starts with a T and a G - it's a long story...). It doesn't matter which code is used.
The code I have used follows, it basically read all the records in to an array and then loops through a replica record set, deletes any occurrences of the number and adds the array value back. While the code works I'm sure there is a cleaner (and faster - their are over 8000 customers to trawl through) way to do this.
' Next Remove any duplicate Numbers
'Set rs = CurrentDb.OpenRecordset("SELECT * FROM TblNoSpace")
'Set rs1 = CurrentDb.OpenRecordset("SELECT * FROM TblNoSpaceFinal")
'With rs
' rs.MoveFirst
' x = 1
' Do Until rs.EOF
' custcode(x) = rs.Fields("lcus_code")
' custname(x) = rs.Fields("lcus_name")
' custphone(x) = rs.Fields("lcus_phone")
' rs.MoveNext
' x = x + 1
' Loop
'End With
'MsgBox ("All REcords copied to Array " & x)
'For y = 1 To x
'With rs1
' rs1.MoveFirst
'
' Do Until rs1.EOF
' If rs1.Fields("lcus_phone") = custphone Then
' rs1.Delete
' End If
' rs1.MoveNext
'
' Loop
' Add Record Back In
' rs1.AddNew
' rs1.Fields("lcus_code") = custcode
' rs1.Fields("lcus_name") = custname
' rs1.Fields("lcus_phone") = custphone
' rs1.Update
' End With
' Me.FrmRecCount1 = y
'Next y
'rs.Close
'rs1.Close
'Set rs = Nothing
'Set rs1 = Nothing