Incrementing case number and save on button click.

D

Dedren

I took some code from another database I did and am trying to work it into my
current one, but having some trouble. Here is the code:

If Me.OnClick Then
Dim strWhere As String
Dim varResult As Variant

strWhere = "CaseNum Like """ & Format(Date, "yy") & "*"""
varResult = DMax("CaseNum", "Cases", strWhere)

If IsNull(varResult) Then
Me.CaseNum = Format(Date, "yy") & "-001"
Else
Me.CaseNum = Left(varResult, 3) & _
Format(Val(Right(varResult, 3)) + 1, "000")
End If
End If
DoCmd.Save

I am making an unbound form that the user enters case info into. When they
hit this save button it creates a unique ID number for this case and saves
the case into its respective tables. The code keeps giving me an error at
Me.CaseNum = Format(Date, "yy") & "-001"
saying "Method or Data member not found"

In the old DB it would activate when the form was Dirtied and Current not
sure if that has anything to do with it.

Thanks in advance for any guidance.
 

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

Top