Access 2000 DMax question

  • Thread starter Thread starter Susan Koziel
  • Start date Start date
S

Susan Koziel

Hi,
I'm using Access 2000, and I've have a form that uses
a default value of
=DMax(" [HiddenCounter] ","DEBM1TBL")+1

And this works well for the form
but when I switch the from to datasheet view it doesn't seem to up date
correctly and I get duplicates of the number occuring.
I've tried using a requery command on the form but that doesn't seem to work
correctly.

I need to know if there is a way around the datasheet giving duplicates?
Thanks.
-Sue
 
Hi,
I'm using Access 2000, and I've have a form that uses
a default value of
=DMax(" [HiddenCounter] ","DEBM1TBL")+1

And this works well for the form
but when I switch the from to datasheet view it doesn't seem to up date
correctly and I get duplicates of the number occuring.
I've tried using a requery command on the form but that doesn't seem to work
correctly.

I need to know if there is a way around the datasheet giving duplicates?
Thanks.
-Sue

Rather than using the default value property, consider using code in the
Form's BeforeInsert event:

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!fieldname = DMax("[HiddenCounter]", "DEBM1TBL") + 1
End Sub
 
John W. Vinson said:
Hi,
I'm using Access 2000, and I've have a form that uses
a default value of
=DMax(" [HiddenCounter] ","DEBM1TBL")+1

And this works well for the form
but when I switch the from to datasheet view it doesn't seem to up date
correctly and I get duplicates of the number occuring.
I've tried using a requery command on the form but that doesn't seem to work
correctly.

I need to know if there is a way around the datasheet giving duplicates?
Thanks.
-Sue

Rather than using the default value property, consider using code in the
Form's BeforeInsert event:

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!fieldname = DMax("[HiddenCounter]", "DEBM1TBL") + 1
End Sub

Thanks John,
That helped, and the Hidden counter field is incrementing correctly...
now I have a different problem.

My hidden counter field was linked to another field that added some
alphanumeric data to the counter.

It's default value is
="DM1-" & [HiddenCounter]

This is used so I can make labels for the items in the database.
However this doesn't update at all now.
In the field I get:
DM1-
but no number showing up for the counter field.
Help
-Sue
 
My hidden counter field was linked to another field that added some
alphanumeric data to the counter.

It's default value is
="DM1-" & [HiddenCounter]

This is used so I can make labels for the items in the database.
However this doesn't update at all now.
In the field I get:
DM1-
but no number showing up for the counter field.

This field is not needed, and should simply not exist.

Instead, set the Format property of the textbox on the label report (or
wherever else you want it shown) to

"DM1-#"

to *display* the prefix, without the need to store it anywhere in any table.
 
Back
Top