Im kind of stuck on this.
I have attached the database.
Im my application, i have a field named call number. what i need that field to do is autoincrement the call number based on the year and month.
Here is what i would like it to do.... the main form is hci cad main 2. on the bottom of the browse, the user clicks the button named add new call. This button will open up a new form named bensondataentry. -
the field named call number will automatically increment based on the year and month. - The call number is based on the following. The year and month start the first three numbers. i.e. year is 1 for 2011, and april is 04. so the first three numbers are 104. the next numbers in the call number are 201. which is the station code. - so the complete number is 104201. the 201 will auto increment when a new call is added. so for example when a new call is added, it becomes 104201- 104202. -- this is based on the current month. so when may 1st, 2011 starts the call number turns into 105201, then will auto increment from the 105201 to 105202. and so on.
i tried to write code without sucess using the increment value() thing.
Here is the code.
i put that code on the onpush on the button for add new call.
Thanks
Sean...
I have attached the database.
Im my application, i have a field named call number. what i need that field to do is autoincrement the call number based on the year and month.
Here is what i would like it to do.... the main form is hci cad main 2. on the bottom of the browse, the user clicks the button named add new call. This button will open up a new form named bensondataentry. -
the field named call number will automatically increment based on the year and month. - The call number is based on the following. The year and month start the first three numbers. i.e. year is 1 for 2011, and april is 04. so the first three numbers are 104. the next numbers in the call number are 201. which is the station code. - so the complete number is 104201. the 201 will auto increment when a new call is added. so for example when a new call is added, it becomes 104201- 104202. -- this is based on the current month. so when may 1st, 2011 starts the call number turns into 105201, then will auto increment from the 105201 to 105202. and so on.
i tried to write code without sucess using the increment value() thing.
Here is the code.
dim tyear as C
dim previd as C
dim prevyear as C
dim nxtid as c
dim nxtnum as N
' get next sequential ID number checking for change of month'
tyear=right(time("yMM"),3)
previd = tablemax("timelogbenson",".T.","callnumber")
prevyear = left(previd,2)
if tyear > prevyear then
nxtid = tyear +"201"
else
nxtid = tyear+increment_value(right(previd,1))
end if
bensondataentry.callnumber.value = nxtid
dim previd as C
dim prevyear as C
dim nxtid as c
dim nxtnum as N
' get next sequential ID number checking for change of month'
tyear=right(time("yMM"),3)
previd = tablemax("timelogbenson",".T.","callnumber")
prevyear = left(previd,2)
if tyear > prevyear then
nxtid = tyear +"201"
else
nxtid = tyear+increment_value(right(previd,1))
end if
bensondataentry.callnumber.value = nxtid
Thanks
Sean...
Comment