Reputation: 1
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!Clear.Visible = False
Me!SearchPurchaseOrderNumber = Null
Me!SearchLotNumber = Null
Dim serialnumber As Variant
serialnumber = Right(DMax("LotNumber", "R01ReceivingFormToday"), 2)
If DCount("LotNumber", "R01ReceivingFormToday") = 0 Then
Me!LotNumber = Me!Today & "-01"
Else
** Me!LotNumber = Format(Me!Today, "000000") & "-" & Format(serialnumber + 1, "00")**
End If
End Sub
I'm getting this Run-time error '13': Type mismatch. when I debug it points to the bolded line. Not sure how to go about this, as it was working perfectly fine for a year until yesterday?
I tried to make sure that in the References dialog box, reference of DAO object library has greater priority, because I read that that is a common issue.. Still no solution so far.
Upvotes: 0
Views: 62
Reputation: 326
Although you declared serialnumber as a Variant, it will be a String value when you evaluate:
Format(serialnumber + 1, "00")
Try:
Format(Val(serialnumber) + 1, "00")
Upvotes: 1