You asked if it is possible to increment by one. I suggested a solution (by
means of the link). Now I learn that you already had code, but it is not
working. Had you mentioned the code in the first place I would not have
responded, as I do not quite understand what you are doing.
Anybody attempting to respond is probably unfamiliar with your database, so
may not know what to make of your remarks about ArticleCode and
ControlNumber. If these are CodigoArtigo and NumeroControlo, it would be
best to just say so and not leave it to potential responders to translate.
I recall that there were a few details in your original post, which brings
me to another point, which is that you should include the text of previous
messages in you reply so that it is not necessary to flip back and forth
between messages.
"NV" <nu*********@potain.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
This is the code I'm using :
strSQL = _
"INSERT INTO RegistoGamas(NumeroGama, NumeroControlo,
CodigoArtigo) " & _
"VALUES('" & Me.NumeroGama & "', #, '" & Me.CodigoArtigo & "')"
lngLastUsedID = Nz(DMax("[NumeroControlo]", "[RegistoGamas]",
"[NumeroGama]=" &_ [txtNumeroGama]), 0)
Set db = CurrentDb
For lngID = (lngLastUsedID + 1) To (lngLastUsedID + lngAddCount)
db.Execute Replace(strSQL, "#", Str(lngID)), dbFailOnError
Next lngID
and it works fine if I use always the same ArticleCode, if I chose
other ArticleCode it will change the ControlNumber of previous records
and will mess it all up
I've looked and looked again but I can't guess what's wrong with this
code