Code Not working

  • Thread starter Thread starter LJG
  • Start date Start date
L

LJG

Hi Guys,

Any idea why this code does not work?

Private Sub Form_BeforeInsert(Cancel As Integer)
Me!txtID = Nz(DMax("[CustNumber]", "[tblContacts]")) + 1
End Sub

Have used it before in another form and works fine, object & table names are
correct

TIA
Les
 
LJG said:
Hi Guys,

Any idea why this code does not work?

Private Sub Form_BeforeInsert(Cancel As Integer)
Me!txtID = Nz(DMax("[CustNumber]", "[tblContacts]")) + 1
End Sub

Have used it before in another form and works fine, object & table
names are correct

What "doesn't work" about it? Do you get an error?
 
No, just does not update the CustNumber, keeps just adding 10000 as the next
number


Rick Brandt said:
LJG said:
Hi Guys,

Any idea why this code does not work?

Private Sub Form_BeforeInsert(Cancel As Integer)
Me!txtID = Nz(DMax("[CustNumber]", "[tblContacts]")) + 1
End Sub

Have used it before in another form and works fine, object & table
names are correct

What "doesn't work" about it? Do you get an error?
 
LJG said:
No, just does not update the CustNumber, keeps just adding 10000 as
the next number

If CustNumber is text then that is what will happen when you get 9999 since the
"max" is alphabetical instead of numeric.
 
Back
Top