trudye10
Programmer
- Sep 8, 2006
- 67
Hi Guys, I'm having a problem with date coversion. I am getting a "Type Mismatch" error, here is a sample of my code. Also is this overkill moving the date so many times?
Function ReFormat_Date()
Dim db1 As Database
Dim rs1 As Recordset
Dim sDate As String
Dim strDate As Date
Set db1 = DBEngine(0)(0)
Set rs1 = db1.OpenRecordset("zz_Export_SC_Record_Layout", dbOpenDynaset)
Do While Not rs1.EOF
rs1.Edit
If Len(rs1!eff_Date) > 0 Then
sDate = rs1!eff_Date
strDate = Format(DateSerial(Left(strDate, 4), Mid(strDate, 5, 2), Right(strDate, 2)), "mmddyyyy")
rs1!eff_Date = sDate
End If
rs1.Update
If Not rs1.EOF Then
rs1.MoveNext
End If
Loop
End Function
Thank so much,
Trudye
Function ReFormat_Date()
Dim db1 As Database
Dim rs1 As Recordset
Dim sDate As String
Dim strDate As Date
Set db1 = DBEngine(0)(0)
Set rs1 = db1.OpenRecordset("zz_Export_SC_Record_Layout", dbOpenDynaset)
Do While Not rs1.EOF
rs1.Edit
If Len(rs1!eff_Date) > 0 Then
sDate = rs1!eff_Date
strDate = Format(DateSerial(Left(strDate, 4), Mid(strDate, 5, 2), Right(strDate, 2)), "mmddyyyy")
rs1!eff_Date = sDate
End If
rs1.Update
If Not rs1.EOF Then
rs1.MoveNext
End If
Loop
End Function
Thank so much,
Trudye