Yes that is the line it is painted red and shows syntax error:
Set rs = db.OpenRecordset("SELECT Max(Mid([Pinigu priemimo kvitas Nr:],5)) AS MaxNum
FROM ppk", dbOpenDynaset)
If I write it on one line like this:
Set rs = db.OpenRecordset("SELECT Max(Mid([Pinigu priemimo kvitas Nr:],5)) AS...