G
Guest
I have the following procedure in which I am trying to update a text field in
tblSys after identifying the current date in the table is more than 30 days
old. The code runs but the value updated in the table is not the text
equivalent of the new date I am trying to add. How can I convert the the
variable strNewdate from a date to a text value so the value in tblSys is
text?
Thank you.
Private Sub Form_Close()
Dim datCurrDate As Date, strSQLNewDate As String, strNewDate
Dim strResetsysTblDate As String
Dim cnnSysTblDate As ADODB.Connection, rsNewDate As Recordset
Dim strSQLUpdateDate As String
datCurrDate = Date
'Gets text date value from tblSys
strResetsysTblDate = DLookup("[ReturnVal]", "tblSys", "[Comparison] =
""Backup""")
'Converts text in sysTbl to date value
strResetsysTblDate = DateValue(strResetsysTblDate) + 30
If datCurrDate > strResetsysTblDate Then
MsgBox "It has been more than 30 days since your last backup " &
vbNewLine & _
"Please consider doing a backup after this form closes " &
vbNewLine & vbNewLine & _
"You will not be reminded for another 30 days "
End If
'assign new date using date variable + 30
strNewDate = Date + 30
'convert strNewDate to a string???????????????
Set cnnSysTblDate = Application.CurrentProject.Connection
Set rsNewDate = New ADODB.Recordset
'open recordset in backend db
rsNewDate.Open Source:="tblSys", ActiveConnection:=cnnSysTblDate, _
CursorType:=adOpenForwardOnly, LockType:=adLockPessimistic
strSQLUpdateDate = "UPDATE tblSys SET [ReturnVal] = " & strNewDate & " WHERE
[Comparison] = 'Backup'"
End Sub
tblSys after identifying the current date in the table is more than 30 days
old. The code runs but the value updated in the table is not the text
equivalent of the new date I am trying to add. How can I convert the the
variable strNewdate from a date to a text value so the value in tblSys is
text?
Thank you.
Private Sub Form_Close()
Dim datCurrDate As Date, strSQLNewDate As String, strNewDate
Dim strResetsysTblDate As String
Dim cnnSysTblDate As ADODB.Connection, rsNewDate As Recordset
Dim strSQLUpdateDate As String
datCurrDate = Date
'Gets text date value from tblSys
strResetsysTblDate = DLookup("[ReturnVal]", "tblSys", "[Comparison] =
""Backup""")
'Converts text in sysTbl to date value
strResetsysTblDate = DateValue(strResetsysTblDate) + 30
If datCurrDate > strResetsysTblDate Then
MsgBox "It has been more than 30 days since your last backup " &
vbNewLine & _
"Please consider doing a backup after this form closes " &
vbNewLine & vbNewLine & _
"You will not be reminded for another 30 days "
End If
'assign new date using date variable + 30
strNewDate = Date + 30
'convert strNewDate to a string???????????????
Set cnnSysTblDate = Application.CurrentProject.Connection
Set rsNewDate = New ADODB.Recordset
'open recordset in backend db
rsNewDate.Open Source:="tblSys", ActiveConnection:=cnnSysTblDate, _
CursorType:=adOpenForwardOnly, LockType:=adLockPessimistic
strSQLUpdateDate = "UPDATE tblSys SET [ReturnVal] = " & strNewDate & " WHERE
[Comparison] = 'Backup'"
End Sub