Type 13 error message

  • Thread starter Thread starter Fay Yocum
  • Start date Start date
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
 
Sorry the other line was suppose to be ' out

The problem is

NewID = Format(Right(OldID, 3) + 1, "000")
Fay
 
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")
 
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
 
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")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Autonumbering 5
Nz and DMax 4
Custom Counter Code 9
Invoice number 5
Autonumber help in form 8
Previous Command No Longer Works 2
Code Optimization 0
Custom Autonumber Help 10

Back
Top