problem in access..

  • Thread starter Thread starter asset number via AccessMonster.com
  • Start date Start date
A

asset number via AccessMonster.com

'Guys need help. How can I do this in Ms access
'My prof has assigned this project to us and im really not into access. i
know a bit of it
'but im not good at it.
'Here's the prob.
'I have two textbox namely year of birth and number
'Now what I need to do is to count the number of user who enters the same
birth year
'for example the user inputs 2004, 001 will automatically be displayed on the
number textbox
'If on the next record the user will also input 2004, 002 will automatically
be displayed
'on the number textbox. Now if on the next record the user will enter a
different year example:
'the user enters 2005, 001 will automatically be displayed on the number
textbox.
'How can i do this?Thanks and hope you can help me.
 
In the After Upate event of the year of birth text box (bad idea to use
spaces in names of objects):

Me.Number = Nz(DMax("[NumberFieldName]", "TableName", _
"[YearFieldName] = " & Me[year of birth]),0) +1

Change NumberFieldName to the name of the field in your table where you
carry the number you want to increment.
Change TableName to the name of the table where the data is.
Change YearFieldName to the name of field in your table that has the year.
The above syntax assumes YearFieldName is a numeric field. If it is a text
field, the syntax will be:
Me.Number = Nz(DMax("[NumberFieldName]", "TableName", _
"[YearFieldName] = '" & Me[year of birth] & "'"),0) +1
 
Back
Top