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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top