Issue with creating a data entry form using dmax - doesn't pick up value

Copper Contributor

 

Hi all,

 

I'm creating a simple data entry for that is used to add new data to a pre-created table

 

I create the form and set the property to data entry

 

I've added the code for DMAX/I've tried DCount too

 

=DMAX("PupilID","tblPupil")+1

 

this finds the largest pupil number and adds one

 

I've done this before and never had the issue but it is giving an error message (see below) 

 

I have 13 records - the dmax finds the largest and then adds one on

 

it automatically shows 14 but as soon as I add another field and try to go to design view or save it thinks there is no value in the ownerID field

 

I've tried different number formats, key on, key off, delete relationships etc but no joy - any help greatly appreciated

 

 

accessissue.png

4 Replies
If you have no records in your table, which you don't, then you'll need to check for null values:

=NZ(DMAX("PupilID","tblPupil"),0)+1

See https://599cd.com/NZ for more help

did you Bind "OwnerID" textbox to OwnerID field?
Hi - I do have records - I think this is an issue with my version of access

previously the ID was generated with an expression in the control source - I added it to default value and it works - useful tip above anyway thanks