The code assumes that your form has controls named FileNo and LogNo. Do you
have both controls on your form?
Although VBA highlights the "[LogNo] = " part, the error could be anywhere
in the line.
I notice that you are running this code in Form_BeforeInsert. Will the LogNo
text box actually have a value at this stage? It might (if there's a default
value), but if not, the code will fail, and you may need to move it into the
AfterUpdate event procedure of the LogNo text box and test it for null:
If Not IsNull(Me.LogNo) Then
Me.FileNo = Nz(DMax("[FileNo]", "tblFiles", "[LogNo] = " &
Me.LogNo), 0) + 1
End If
I've also suggested supplying the 2nd argument for Nz().

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
> Hi I have the following code:
>
[quoted text clipped - 14 lines]
>
> Can anyone offer any help?