Hey guys, it's been a while since I was last here. Personal issues kept me otherwise occupied. (prev. known as startingover).
ANYhoo...I'm having a dandy of a time with one line in this code. I'm getting error on line 20, error 94 - invalid use of null.
Now, I have looked all over creation on here and other sites and all I seem to find even remotely close is all SQL. Don't want SQL. Don't need SQL. I love SQL but only where it's needed. Not for this.
It's something simple I just know it is.
On any of the comparisons, it works just fine, but when the date is a null value b/c it hasn't been put in yet, I get the above listed error on line 20. I've tried converting it but to no avail. It is only the year value but the current year and the recorded year need to match. Again, the issue is when comparing to a blank date, it throws an error. I do have a workaround but it's really not my favorite idea.
Private Sub HandleDate()
10 On Error GoTo HandleDate_Err
20 Me.txtRecordedYear = Nz(Year(Me.W4Date))
30 Me.txtCurrentDateYear = Year(Date)
40 If Me.NewRecord Then
50 Me.txtCurrentDateYear = Year(Date)
60 Me.lblw4Year.Caption = " - New"
70 Me.lblw4Year.ForeColor = RGB(164, 213, 226)
80 End If
90 If Me.Verified = -1 And Me.txtRecordedYear = Me.txtCurrentDateYear Then
100 Me.lblw4Year.Caption = " - " & Me.txtRecordedYear
110 Me.lblw4Year.ForeColor = RGB(164, 213, 226)
120 End If
130 If Me.Verified = 0 And Me.txtRecordedYear <> Me.txtCurrentDateYear Then
140 Me.lblw4Year.Caption = " - " & Me.txtRecordedYear
150 Me.lblw4Year.ForeColor = vbRed
160 End If
HandleDate_Exit:
170 Exit Sub
HandleDate_Err:
180 Select Case Err.Number
Case 94
190 MsgBox "Error at line #: " & Erl & vbCrLf & _
"Error #: " & Err.Number & vbCrLf & _
"Description: " & Err.Description & vbCrLf & _
"Location: Private Sub HandleDate()"
200 Case 2501
210 MsgBox "some message"
220 Case Else
230 MsgBox "Error at line: " & Erl & " " & Err.Number & "--" & Err.Description
240 End Select
250 Resume HandleDate_Exit
End Sub
Thx guys.
ANYhoo...I'm having a dandy of a time with one line in this code. I'm getting error on line 20, error 94 - invalid use of null.
Now, I have looked all over creation on here and other sites and all I seem to find even remotely close is all SQL. Don't want SQL. Don't need SQL. I love SQL but only where it's needed. Not for this.
It's something simple I just know it is.
On any of the comparisons, it works just fine, but when the date is a null value b/c it hasn't been put in yet, I get the above listed error on line 20. I've tried converting it but to no avail. It is only the year value but the current year and the recorded year need to match. Again, the issue is when comparing to a blank date, it throws an error. I do have a workaround but it's really not my favorite idea.
Private Sub HandleDate()
10 On Error GoTo HandleDate_Err
20 Me.txtRecordedYear = Nz(Year(Me.W4Date))
30 Me.txtCurrentDateYear = Year(Date)
40 If Me.NewRecord Then
50 Me.txtCurrentDateYear = Year(Date)
60 Me.lblw4Year.Caption = " - New"
70 Me.lblw4Year.ForeColor = RGB(164, 213, 226)
80 End If
90 If Me.Verified = -1 And Me.txtRecordedYear = Me.txtCurrentDateYear Then
100 Me.lblw4Year.Caption = " - " & Me.txtRecordedYear
110 Me.lblw4Year.ForeColor = RGB(164, 213, 226)
120 End If
130 If Me.Verified = 0 And Me.txtRecordedYear <> Me.txtCurrentDateYear Then
140 Me.lblw4Year.Caption = " - " & Me.txtRecordedYear
150 Me.lblw4Year.ForeColor = vbRed
160 End If
HandleDate_Exit:
170 Exit Sub
HandleDate_Err:
180 Select Case Err.Number
Case 94
190 MsgBox "Error at line #: " & Erl & vbCrLf & _
"Error #: " & Err.Number & vbCrLf & _
"Description: " & Err.Description & vbCrLf & _
"Location: Private Sub HandleDate()"
200 Case 2501
210 MsgBox "some message"
220 Case Else
230 MsgBox "Error at line: " & Erl & " " & Err.Number & "--" & Err.Description
240 End Select
250 Resume HandleDate_Exit
End Sub
Thx guys.