Button to Display Last Number

  • Thread starter Thread starter zat via AccessMonster.com
  • Start date Start date
Z

zat via AccessMonster.com

The form I have developed allows users to input Change Order Numbers; however,
they are wanting a button that when they click on it it displays the last
change order number that was inputted. Could someone tell me the code I
would use to develope this? Would I use a command button or a label? Thanks!
 
Do you want to go to the last record? In that case, you can use the
built-in navigation button or add code to a command button:
DoCmd.GoToRecord , , acLast
If you want to just display the highest value in a text box txtHighest, the
command button Click event could be:
Me.txtHighest = DMax("YourField","YourTable")
Use your actual field and table names, of course. You will need to clear
the text box in the form's Current event if you want it to be blank when you
move to another record (Me.txtHighest = Null).
If you want the highest value always to be displayed on the form, an unbound
text box on the form could contain the expression as its control source:
= DMax("YourField","YourTable")
If the point of seeing the number is for the user to select the next one,
consider an automated system. Whether the number is being assigned by the
user or by code, keep in mind that in a multi-user environment you will need
to guard against duplication.
 
Thanks!
Do you want to go to the last record? In that case, you can use the
built-in navigation button or add code to a command button:
DoCmd.GoToRecord , , acLast
If you want to just display the highest value in a text box txtHighest, the
command button Click event could be:
Me.txtHighest = DMax("YourField","YourTable")
Use your actual field and table names, of course. You will need to clear
the text box in the form's Current event if you want it to be blank when you
move to another record (Me.txtHighest = Null).
If you want the highest value always to be displayed on the form, an unbound
text box on the form could contain the expression as its control source:
= DMax("YourField","YourTable")
If the point of seeing the number is for the user to select the next one,
consider an automated system. Whether the number is being assigned by the
user or by code, keep in mind that in a multi-user environment you will need
to guard against duplication.
 
Back
Top