Table update form a subform

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

Guest

Hello.

I have a form with a continuous subform. I have in this subform a field
called [ArtNumber] with the predefined value:
=Nz(DMax("ArtNumber";"tblArticles"))+1

The idea is that when I enter a new record in this subform, the field
[ArtNumber] gives me the number automatically. However, when I enter a new
record the following record has the same number. Only if I close the form,
the following number changes to the correct one.
I think it is a problem with the table update. Any one can help me, please?

Thank you in advance.

Acores
 
Hi Acores,

If you are simply incrementing your number, could you not use an autonumber
field?

Damian.
 
Hello Damian. Thank you for your fast answer.

But if I use a Autonumber field, what happens if I delete one? There will be
gaps, and I need that all the numbers are sequential.

Isnt'it so?

Thanl you again.

Acores

"Damian S" escreveu:
Hi Acores,

If you are simply incrementing your number, could you not use an autonumber
field?

Damian.

acores said:
Hello.

I have a form with a continuous subform. I have in this subform a field
called [ArtNumber] with the predefined value:
=Nz(DMax("ArtNumber";"tblArticles"))+1

The idea is that when I enter a new record in this subform, the field
[ArtNumber] gives me the number automatically. However, when I enter a new
record the following record has the same number. Only if I close the form,
the following number changes to the correct one.
I think it is a problem with the table update. Any one can help me, please?

Thank you in advance.

Acores
 
' aquí simplemente se le da un número correlativo al campo IdFactura,
' pero podría ser conveniente cotejar este valor con el que aparece
' en el control txtIdFactura, y en caso de ser diferentes, enviar
' un mensaje informativo al usuario.
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Me.IdFactura = Nz(DMax("IdFactura", "Facturas")) + 1
End If
End SubCodigo y autoria Juan M Afán de Ribera
 
Back
Top