10 replies
by sgt_shultz
technet.microsoft.com has articles how to do a counter in vb code. which is what i think you want.
you would hook macro doing the incrementing to an event on your form (like updating the field maybe). the vb code would look something like this i think:
dim counter
counter = formname!fieldname
counter = counter + 1
formname!fieldname = counter
you will have to add a form refresh to see the change...many free sample forms are available along with the vb help file explaining how they work on the second Office installation cd i think in the tools folder.
by lwwilliams
by lwwilliams
by jesus h
All you have to do is use Dmax to get the highest number, add 1 to it and then assign it to your new record
DLast will give you the last record
Dmax will give you the highst value
The code might look something like this:
Private Sub Freight_DblClick(Cancel As Integer)
Dim curY
curY = DLast ("[Freight]", "Orders")
' Add a New Record
DoCmd.GoToRecord , , acNewRec
' assign new value to
Forms!Frm_Orders!Freight = curY + 1
End Sub
by lwwilliams
by jesus h
In the third line replace "Assembly" with the table's name, and "Rework Number" with the name of the field in that table.
if the table's name is "Assembly" (same as the form)
and field's name is "Rework Number" (same as the form)
the code should look like:
Private Sub Rework_Number_Click()
Dim curY
curY = DLast("[Rework Number]", "Assembly")
' Add a New Record
DoCmd.GoToRecord , , acNewRec
' assign new value to
Forms!Assembly![Rework Number] = curY + 1
End Sub
Note, it executes the code once you click on the field "Rework Number" ( Private Sub Rework_Number_Click() )
by sgt_shultz
rookie is ok. helpless is not.
sigh.
here you go:
ACC2000: How to Use DAO to Programmatically Add an AutoNumber Field to a Table
ACC2000: How to Use DAO to Programmatically Add an AutoNumber Field to a Table
the sample forms are free for download, did you have a look?
my home page is support.microsoft.com
by sgt_shultz
oops. meant for the link to get in there:
http://support.microsoft.com/kb/210405/en-us
by sgt_shultz
this one might be better:
ACC2000: How to Create a Multiuser Custom Counter
http://support.microsoft.com/kb/210194/en-us
i think this was the first thing i learned how to do in vba. i think it took me 6 months (rdl) after that it was all quite a bit easier.
by sgt_shultz
ACC2000: Referring to a Field in the Previous Record or Next Record
http://support.microsoft.com/kb/210504/en-us
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending