Hello Guys,
The following code worked in another form and returns a string but
I am getting run-time error 3021 from my code. When I step through it sqlDateEarned shows a value but the value is not transmitting to strDateEarned so I am getting the error message. Can you please help me. (It is support to return a date).
Thank you,
The following code worked in another form and returns a string but
I am getting run-time error 3021 from my code. When I step through it sqlDateEarned shows a value but the value is not transmitting to strDateEarned so I am getting the error message. Can you please help me. (It is support to return a date).
Code:
Private Sub cmdDateEarned_Click()
Dim sqlDateEarned As String
Dim strDateEarned As Date
sqlDateEarned = "SELECT DateEarned FROM [QryPE] WHERE DateEarned=#" & Me.DateEarned.Value & "# AND FName='" & Me.cboFName.Column(1) & "' AND [State]='" & Me.cboStates.Value & "'"
strDateEarned = CurrentDb.OpenRecordset(sqlDateEarned).Fields(0).Value
If IsNull(strDateEarned) Then
MsgBox "There is no earned date for this license", vbCritical, "No Date Earned"
Else
MsgBox "This license was earned on " & strDateEarned & ".", , "Date Earned"
End If
End Sub
Thank you,