PSUIVERSON
Technical User
I am doing some simple formatting of data that I imported into fields and when it gets down to the dates section of the code it just RUNS and RUNS and RUNS. I have to do a CTRL Break because I can't figure it out. It shouldn't take so long...should it?
Sub formatTABLE()
Dim dbs As Database
Dim rst As Recordset
Dim i As Integer
Dim temp As Variant
Dim temp2 As Variant
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("TEST", dbOpenDynaset)
rst.MoveFirst
' Format SS#
temp = Mid(rst!CSSNO, 4, 1)
If temp <> "-" Then
Do
temp = rst!CSSNO
temp2 = Left(temp, 3) + "-" + Mid(temp, 4, 2) + "-" + Right(temp, 6)
rst.Edit
rst!CSSNO = temp2
rst.Update
rst.MoveNext
Loop Until rst.EOF
End If
'Format IDCRATE
rst.MoveFirst
Do
temp = rst!CIDCRATE
If temp <> "" And temp > 100 Then
temp = FormatNumber(rst!CIDCRATE / 100, 2)
rst.Edit
rst!CIDCRATE = temp
rst.Update
End If
rst.MoveNext
Loop Until rst.EOF
'Format STARTBAL
rst.MoveFirst
Do
temp = Round((rst!startbal * -1), 2)
If temp <> 0 Then
rst.Edit
rst!startbal = temp
rst.Update
End If
rst.MoveNext
Loop Until rst.EOF
'Clean up the Dates
rst.MoveFirst
Do
temp = Left(rst!DATE3, 1)
If temp = "." Then
i = Len(rst!DATE3)
temp = Right(rst!DATE3, i - 1)
rst.Edit
rst!DATE3 = temp
rst.Update
rst.MoveNext
End If
Loop Until rst.EOF
rst.MoveFirst
Do
temp = Left(rst!DATE2, 1)
If temp = "." Then
i = Len(rst!DATE2)
temp = Right(rst!DATE2, i - 1)
rst.Edit
rst!DATE2 = temp
rst.Update
rst.MoveNext
End If
Loop Until rst.EOF
rst.MoveFirst
Do
temp = Left(rst!DATE1, 1)
If temp = "." Then
i = Len(rst!DATE1)
temp = Right(rst!DATE1, i - 1)
rst.Edit
rst!DATE1 = temp
rst.Update
rst.MoveNext
End If
Loop Until rst.EOF
'Alert user they have finished
MsgBox ("You have finished formatting the XYZ table"
dbs.Close
End Sub
Sub formatTABLE()
Dim dbs As Database
Dim rst As Recordset
Dim i As Integer
Dim temp As Variant
Dim temp2 As Variant
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("TEST", dbOpenDynaset)
rst.MoveFirst
' Format SS#
temp = Mid(rst!CSSNO, 4, 1)
If temp <> "-" Then
Do
temp = rst!CSSNO
temp2 = Left(temp, 3) + "-" + Mid(temp, 4, 2) + "-" + Right(temp, 6)
rst.Edit
rst!CSSNO = temp2
rst.Update
rst.MoveNext
Loop Until rst.EOF
End If
'Format IDCRATE
rst.MoveFirst
Do
temp = rst!CIDCRATE
If temp <> "" And temp > 100 Then
temp = FormatNumber(rst!CIDCRATE / 100, 2)
rst.Edit
rst!CIDCRATE = temp
rst.Update
End If
rst.MoveNext
Loop Until rst.EOF
'Format STARTBAL
rst.MoveFirst
Do
temp = Round((rst!startbal * -1), 2)
If temp <> 0 Then
rst.Edit
rst!startbal = temp
rst.Update
End If
rst.MoveNext
Loop Until rst.EOF
'Clean up the Dates
rst.MoveFirst
Do
temp = Left(rst!DATE3, 1)
If temp = "." Then
i = Len(rst!DATE3)
temp = Right(rst!DATE3, i - 1)
rst.Edit
rst!DATE3 = temp
rst.Update
rst.MoveNext
End If
Loop Until rst.EOF
rst.MoveFirst
Do
temp = Left(rst!DATE2, 1)
If temp = "." Then
i = Len(rst!DATE2)
temp = Right(rst!DATE2, i - 1)
rst.Edit
rst!DATE2 = temp
rst.Update
rst.MoveNext
End If
Loop Until rst.EOF
rst.MoveFirst
Do
temp = Left(rst!DATE1, 1)
If temp = "." Then
i = Len(rst!DATE1)
temp = Right(rst!DATE1, i - 1)
rst.Edit
rst!DATE1 = temp
rst.Update
rst.MoveNext
End If
Loop Until rst.EOF
'Alert user they have finished
MsgBox ("You have finished formatting the XYZ table"

dbs.Close
End Sub