Hi,
I am trying to add new record in my form. I have displayed my last used reference number of the letter I issued.
The format of my letter reference is something like "INAT/HR/20/2004"
Whereas ""INAT/HR/" portion will be with each letter and then "20" indicates the current year and last 4 digits are showing my actual sequence numbers of letters.
TxtLastRef is the text box which displays last used ref. number.
What I am looking for is if I clickn on CmdNewOffLetter button it should collected somepart of previous reference and then add the current year with / and add 1 into the last ref sequence number. To get this, I tried below but produces "Run-time error 13" - Type mismatch
Code Tags Added by UG
Please use Code Tags when posting VBA Code
https://www.access-programmers.co.u...e-use-code-tags-when-posting-vba-code.240420/
Please help me.
Thanks,
Ashfaque
I am trying to add new record in my form. I have displayed my last used reference number of the letter I issued.
The format of my letter reference is something like "INAT/HR/20/2004"
Whereas ""INAT/HR/" portion will be with each letter and then "20" indicates the current year and last 4 digits are showing my actual sequence numbers of letters.
TxtLastRef is the text box which displays last used ref. number.
What I am looking for is if I clickn on CmdNewOffLetter button it should collected somepart of previous reference and then add the current year with / and add 1 into the last ref sequence number. To get this, I tried below but produces "Run-time error 13" - Type mismatch
Code Tags Added by UG
Please use Code Tags when posting VBA Code
https://www.access-programmers.co.u...e-use-code-tags-when-posting-vba-code.240420/
Code:
Private Sub CmdNewOffLetter_Click()
Dim TxtRef, LastNum, RefYear
RefYear = Format(Now, "YY")......this produces 20
TxtRef = Left(TxtLastRef, 8).......... This gets INAT/HR/
LastNum = Right(TxtLastRef, 4)....And this brings 2004 as last sequence of letter.
LastNum = LastNum + 1
Me.LetterRefNumber = TxtRef + RefYear + "/" + LastNum ........Error line....
End Sub
Thanks,
Ashfaque
Last edited by a moderator: