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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|