Never use Macros and not sure you could accomplish this with a Macro. That said here's some code that should get you started in the right direction...
Company Name: Access Diva
ID that will generated: ACC0001
Side note: If there is more than one Company that starts with ACC the below code will go to ACC0002
Code:
Dim lngCountIDs As Long
‘Find how many Companies start with the same three letters and count plus one
lngCountIDs = Nz(DCount("Right(cCompanyID,3),", "tblCompanies", "Left(cCompanyID,3) = '" & Left(Me.txtCompanyName, 3) & "'"), 0) + 1
Me.txtCompanyID = StrConv(Trim(Left(Me.txtCompanyName, 3)), vbUpperCase) & Format(lngCountIDs, "0000")
DoCmd.RunCommand acCmdSaveRecord