E
Enderjit Singh
So far the help of the Bruce and Ron to name just two. I
have got this far in my query. I am trying convert text
records in a feild from a format of DDMMYY to YYYYMMDD,
ignoring records that are blank.
This is the complete code that I currently have in place:
Function Change_date16()
Dim wait As Database, rbk As Recordset
Set wait = DBEngine.Workspaces(0).Databases(0)
Set rbk = wait.OpenRecordset("OP WL CMDS (RBK02)")
rbk.MoveFirst
While Not rbk.EOF
'This assumes that the recordset variable is named "rbk"
If Len(rbk![LastDNAdate] & "") <> 6 Then
'Do nothing - does not meet specified format, or is
Null
Else
'Modify the value
LastDNAdate = Format(DateSerial(Right(rbk!
[LastDNAdate], 2), Mid(rbk![LastDNAdate], 3, 2), Left(rbk!
[LastDNAdate], 2)), "yyyymmdd")
End If
rbk.Edit
rbk![LastDNAdate] = LastDNAdate
rbk.Update
rbk.MoveNext
Wend
End Function
The problem is that when I run this code it does not
always ignore the blank fields, instead it inserts a
YYYYMMYY figure in the field. What am I doing wrong?
have got this far in my query. I am trying convert text
records in a feild from a format of DDMMYY to YYYYMMDD,
ignoring records that are blank.
This is the complete code that I currently have in place:
Function Change_date16()
Dim wait As Database, rbk As Recordset
Set wait = DBEngine.Workspaces(0).Databases(0)
Set rbk = wait.OpenRecordset("OP WL CMDS (RBK02)")
rbk.MoveFirst
While Not rbk.EOF
'This assumes that the recordset variable is named "rbk"
If Len(rbk![LastDNAdate] & "") <> 6 Then
'Do nothing - does not meet specified format, or is
Null
Else
'Modify the value
LastDNAdate = Format(DateSerial(Right(rbk!
[LastDNAdate], 2), Mid(rbk![LastDNAdate], 3, 2), Left(rbk!
[LastDNAdate], 2)), "yyyymmdd")
End If
rbk.Edit
rbk![LastDNAdate] = LastDNAdate
rbk.Update
rbk.MoveNext
Wend
End Function
The problem is that when I run this code it does not
always ignore the blank fields, instead it inserts a
YYYYMMYY figure in the field. What am I doing wrong?