Hello,
I have the following code which searches for the last sequence number in the table in order to create folders. If there is more than one project number I would like for those records to output with the sequence number and an "a" or "b" etc. The following works ok but starts the first one with a "b" rather than "a". What is the best way to alter this to do that? Thank you in advance.
Code:If IsNull(frm.SequenceNum) Or (frm.SequenceNum = 0) Then Dim intLastSeqNum As Integer intLastSeqNum = Nz(DMax("SequenceNum", "tbl_EstimateLog", "intYear = " & intMyYear), 0) 'searching for last seq number for current year Dim tReq As String Dim db As DAO.Database Dim Records As DAO.Recordset Dim strSQL As String Set db = CurrentDb tReq = "select tbl_Requests.txtprojectnumber from tbl_Requests " & _ " where tbl_Requests.[txtProjectNumber] = '" & frm.txtProjectNumber.Value & "'" Set Records = db.OpenRecordset(tReq) If Records.RecordCount > 0 Then Dim strLetter As String Dim i As Integer strLetter = "a" For i = 1 To 26 'I PREVIOUSLY HAD 0 To 26 but returned the same result of "b" strLetter = Chr(Asc(strLetter) + 1) Next i frm.SequenceNum.Value = intLastSeqNum & strLetter Else frm.SequenceNum.Value = intLastSeqNum + 1 End If End If