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
|
|||
|
|||
setting dynamic values to a field
hi
A book table in a library contains the "book's number" and the "copy number". I want to set a default in the Books form, in which for new book entries, after choosing the book number, the "Copy num" field will get automatically the N+1 number (one after the last existing copy). Can I? Thanks, Yaniv |
#2
|
|||
|
|||
setting dynamic values to a field
On Mon, 22 Sep 2008 10:31:09 -0700 (PDT), ???? ??????
wrote: hi A book table in a library contains the "book's number" and the "copy number". I want to set a default in the Books form, in which for new book entries, after choosing the book number, the "Copy num" field will get automatically the N+1 number (one after the last existing copy). Can I? Thanks, Yaniv Your best bet here may be to use the AfterUpdate event of the book number control (because only then will you be able to identify the copy number). Try code something like Private Sub BookNum_AfterUpdate() If Me.NewRecord Then ' only increment on new records Me!CopyNum = NZ(DMax("[CopyNum]", "[BookTable]", _ "[BookNum] = " & Me!BookNum)) + 1 End If End Sub Adapt with your own field and tablenames of course. -- John W. Vinson [MVP] |
#3
|
|||
|
|||
setting dynamic values to a field
On Sep 23, 1:11*am, John W. Vinson
wrote: On Mon, 22 Sep 2008 10:31:09 -0700 (PDT), ???? ?????? wrote: hi A book table in a library contains the "book's number" and the "copy number". I want to set a default in the Books form, in which for new book entries, after choosing the book number, the "Copy num" field will get automatically the N+1 number (one after the last existing copy). Can I? Thanks, Yaniv Your best bet here may be to use the AfterUpdate event of the book number control (because only then will you be able to identify the copy number). Try code something like Private Sub BookNum_AfterUpdate() If Me.NewRecord Then ' only increment on new records * *Me!CopyNum = NZ(DMax("[CopyNum]", "[BookTable]", _ * * * * * "[BookNum] = " & Me!BookNum)) + 1 End If End Sub Adapt with your own field and tablenames of course. -- * * * * * * *John W. Vinson [MVP] It is Working! thank you very much Yaniv |
Thread Tools | |
Display Modes | |
|
|