Setting Default Value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to set the default value for a field to incriment by 1 every time data
is entered. I received the following code from this page (Sorry but I don't
remember where or who from) but it won't work. I am trying to put it as the
default value in the table.

Should I put it as the default value on the form where the data is entered?

The error I get states that there is an "Unknown function "Nz" in the
validation or default value of Device Id List.EquipID"


=Nz(DMax("[EquipID]","Device_Id_List"),0)+1

Any Sugestions?
 
You can't use that expression as the default value for a field in a table.
You could try to use it as the default value for a control on a form.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Should it work if I set it (or how would I need to change it) to run useing
the "on open" event trigger?
Thanks for your help so far.

John Spencer said:
You can't use that expression as the default value for a field in a table.
You could try to use it as the default value for a control on a form.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Ron Corbin said:
I want to set the default value for a field to incriment by 1 every time
data
is entered. I received the following code from this page (Sorry but I
don't
remember where or who from) but it won't work. I am trying to put it as
the
default value in the table.

Should I put it as the default value on the form where the data is
entered?

The error I get states that there is an "Unknown function "Nz" in the
validation or default value of Device Id List.EquipID"


=Nz(DMax("[EquipID]","Device_Id_List"),0)+1

Any Sugestions?
 
Place it in the Form_Current sub and use NewRecord to only assign it if
you're entering a new record:

Private Sub Form_Current()

If Me.NewRecord Then
Me.YourEquipID.Value = Nz(DMax("[EquipID]","Device_Id_List"),0)+1
End If

End Sub
 

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