Jeremy
Would it help to treat the number as a text string by using the format command?
strID = format(MyAutoNumber,"00000000")
strYear = datepart("yyyy",date())
strMyNewID = strYear & "RCN" & strID
I have broken it out a bit; a more typical way of coding would be the example LittleSmudge provided.
Your second question seems to be a two parter...
- search by control number
- combine the date and autonumber and generate the unique identifier for the new record.
Generating the unique identifier is the easier task. Use the "Before Insert" event. By the time this event is ready to execute, you will have generated your autonumber. Now just plug the code in that you choose to use to generate the unique identifier. For example...
Me.strID = datepart("yyyy",date()) & "RCN" & format(MyAutoNumber,"00000000")
Where Me.strID is the field on the form you use to display the unique identifier.
Querying an intellegent record identifier takes a bit of work. But not too hard. This is one approach.
You can use one or two unbound combo boxes on the form. With two, one would use the year and the second combo box would accept the control number. Then you have to put the two together to retrieve the record. An improvement would be that once a person has selected the year, the second combo box would only include controls for the year.
A variation would be for the second combo box to accept a number, and then use the format command to retrieve the record.
With one combo box, you are limited to entering the year and following through with the typing in the leading zeros and the control number.
Richard