Table update form a subform

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
 
G

Guest

Hi Acores,

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

Damian.
 
G

Guest

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
 
F

Freddy M. Aragón C.

' 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
 

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

Top