Type 13 error message

F

Fay Yocum

I can't find the error here. I all of a sudden have started to get a type
mismatch Error 13 message. Any help would be appreciated.

Private Sub txtClassification_AfterUpdate()
Dim NewID As String
Dim OldID As String
If txtClassification = "Staff" Or txtClassification = "Inhouse Agency"
Then
OldID = Nz(DMax("Right(LearnerID,3)", "tblLearners",
"Left(LearnerID,1)<>'A' And Left(LearnerID,1)<>'M' And
Left(LearnerID,1)<>'G' And Left(LearnerID,1)<>'S' "), "586")
NewID = Format(Right(OldID, 3) + 1, "000")
If Val(OldID) < 1000 Then
NewID = Format(Right(OldID, 3) + 1, "000")
Else
NewID = Format(Right(OldID, 4) + 1, "0000")
End If
Me.LearnerID = NewID
ElseIf txtClassification = "Manager" Then
OldID = Nz(DMax("Right(LearnerID,4)", "tblLearners",
"left(LearnerID,1)='M'"), "0000")
NewID = Format("M-") & Format(Right(OldID, 4) + 1, "0000")
Me.LearnerID = NewID
ElseIf txtClassification = "Agency" Then
OldID = Nz(DMax("Right(LearnerID,4)", "tblLearners",
"left(LearnerID,1)='A'"), "0000")
NewID = Format("A-") & Format(Right(OldID, 4) + 1, "0000")
Me.LearnerID = NewID
ElseIf txtClassification = "Guest" Then
OldID = Nz(DMax("Right(LearnerID,4)", "tblLearners",
"left(LearnerID,1)='G'"), "0000")
NewID = Format("G-") & Format(Right(OldID, 4) + 1, "0000")
Me.LearnerID = NewID
ElseIf txtClassification = "Sister" Then
OldID = Nz(DMax("Right(LearnerID,4)", "tblLearners",
"left(LearnerID,1)='S'"), "0000")
NewID = Format("S-") & Format(Right(OldID, 4) + 1, "0000")
Me.LearnerID = NewID
End If
End Sub


Fay
 
F

Fay Yocum

Sorry the other line was suppose to be ' out

The problem is

NewID = Format(Right(OldID, 3) + 1, "000")
Fay
 
D

Douglas J. Steele

You've declared OldID (and NewID, for that matter) as strings, yet you're
trying to do arithmetic on them (at least, I'm assuming you're trying to
increment their value by one)

Try:

NewID = Format(CLng(Right(OldID, 3)) + 1, "000")
 
F

Fay Yocum

I got it figured out. I had marked a questionable record with *** in the
base table. Thanks for your help I got my act together now, I think. Again
thank you for your time. Fay
 
E

eyal

attach
Douglas J. Steele said:
You've declared OldID (and NewID, for that matter) as strings, yet you're
trying to do arithmetic on them (at least, I'm assuming you're trying to
increment their value by one)

Try:

NewID = Format(CLng(Right(OldID, 3)) + 1, "000")
 
Top