larrydavid
Programmer
Hello,
The versions I'm using are SQL Server 2005 and MS Access 2003 sp3. I have a function which the user will use to update an approve/unapprove bit flag in the SQL table. This is fine, but the dates in the WHERE filter are giving me a problem. The data type for the date in the SQL table is smalldatetime (2013-01-12 13:23:00) and the date format in Access is
(1/12/2013 1:23:00 PM). If someone could please show me how to format either date in my vba code so I don't get a data type mismatch I would greatly appreciate it. The date in question is written as [Test_Date] below.
Private Sub chkTestRecordsApproval_Click()
Dim temp As String
Dim strSQL As String
Dim dbs As DATABASE
Set dbs = CurrentDb()
If Me.chkTestRecordsApproval.Value = True Then
temp = MsgBox("Are you sure you want to Approve this?", vbYesNoCancel)
If temp = vbYes Then
strSQL = "UPDATE dbo_Test_Records_Detail SET [Approved] = 'True' WHERE [Test_Date] = '" & Me.Test_Date & "'"
dbs.Execute (strSQL)
Set dbs = Nothing
Me.chkTestRecordsApproval.Value = True
Else
Me.chkTestRecordsApproval.Value = False
End If
End If
End Sub
Thanks,
Larry
The versions I'm using are SQL Server 2005 and MS Access 2003 sp3. I have a function which the user will use to update an approve/unapprove bit flag in the SQL table. This is fine, but the dates in the WHERE filter are giving me a problem. The data type for the date in the SQL table is smalldatetime (2013-01-12 13:23:00) and the date format in Access is
(1/12/2013 1:23:00 PM). If someone could please show me how to format either date in my vba code so I don't get a data type mismatch I would greatly appreciate it. The date in question is written as [Test_Date] below.
Private Sub chkTestRecordsApproval_Click()
Dim temp As String
Dim strSQL As String
Dim dbs As DATABASE
Set dbs = CurrentDb()
If Me.chkTestRecordsApproval.Value = True Then
temp = MsgBox("Are you sure you want to Approve this?", vbYesNoCancel)
If temp = vbYes Then
strSQL = "UPDATE dbo_Test_Records_Detail SET [Approved] = 'True' WHERE [Test_Date] = '" & Me.Test_Date & "'"
dbs.Execute (strSQL)
Set dbs = Nothing
Me.chkTestRecordsApproval.Value = True
Else
Me.chkTestRecordsApproval.Value = False
End If
End If
End Sub
Thanks,
Larry