A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

New Record



 
 
Thread Tools Display Modes
  #1  
Old January 30th, 2010, 07:29 PM posted to microsoft.public.access.gettingstarted
Yogi
external usenet poster
 
Posts: 31
Default New Record

Please help me,,i'm new in ms acces 2003

I have a Form that have a Field called [code],,,i want this field is
automatically inserted with the last record code's +1,,for the first record i
want to use code like A0001,,,after i save it and want to add new record the
field is automatically inserted with A0002,, and it only changed when i want
to add new record.

thanks for your help
  #2  
Old January 30th, 2010, 10:46 PM posted to microsoft.public.access.gettingstarted
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default New Record

This hsould do what you want:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
If RecordsetClone.RecordCount = 0 Then
Me.Code = "A0001"
Else
Me.Code = "A" & Format(DMax("val(Right([code],4))", "YourTableName") + 1,
"0000")
End If
End If
End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-gettingstarted/201001/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:18 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.