Ajax,
I was trying to enumerate each company by its alpha designation where Echelon = "CO". The last code I posted works, but I was looking for a simplified code for it
I planned on using the first style code I posted.
Instead of having to replace the Alphabet Character A with the next sequence letter until J.
Example:
If rv![Netbase] Like "A *" And rv![Echelon] = "CO" Then
If rv![Netbase] Like "B *" And rv![Echelon] = "CO" Then
If rv![Netbase] Like "C *" And rv![Echelon] = "CO" Then
I could run a loop around it
For Cnt = 1 to 10
If rv![Netbase] Like "A *" And rv![Echelon] = "CO" Then
SequenceNumber = Cnt
Next N
Substituting a character set such as Letters = Chr(64 + Cnt) This gives me A through J
Then developing a code something like this:
Code:
Private Sub COLevel_Click()
Dim rv As DAO.Recordset, Cnt As Integer, Z As Integer, Letters As String
Set rv = CurrentDb.OpenRecordset("Units")
If rv.BOF And rv.EOF Then
rv.Close
Else
rv.MoveLast
rv.MoveFirst
Do While Not rv.EOF
For Cnt = 1 To 10
Letters = Chr(64 + Cnt)
If rv![Netbase] Like "'" & Letters And " * '" And rv![Echelon] = "CO" Then
Z = Cnt
Else
Z = 0
rv.Edit
rv!COID = Z
rv.Update
rv.MoveNext
End If
Next Cnt
Loop
End If
rv.Close
Set rv = Nothing
End Sub
But I get a type mismatch 13 error on:
If rv![Netbase] Like "'" & Letters And " * '" And rv![Echelon] = "CO" Then
COID Update.accdb
I am gathering it has something to do with the quotes