Connecting Tech Pros Worldwide Forums | Help | Site Map

datepart problem in VB code

funfair
Guest
 
Posts: n/a
#1: Dec 28 '05
Hi,
I'm facing a strange problem in access 2003 i dont know how to solve it

i have a code in VB which give an autonumber but in finanical new year
it reset to 1 on new year it works in one form but the same code doesnt
work in other form in run time it's going to skip if satatement of date
part to check if month is 4 or not
what is the problem ?
i have looked in the net and i read somehting about reference what
should i do about it .
i'm superized sience it work in form and doesnt work in other in the
same data base .
if i do the forms to be model does it effect?
thank you all
please help me im in a big trouble
how could i solve the problem?


funfair
Guest
 
Posts: n/a
#2: Dec 30 '05

re: datepart problem in VB code


help no one can know what is the problem
please

Wayne Gillespie
Guest
 
Posts: n/a
#3: Dec 30 '05

re: datepart problem in VB code


On 30 Dec 2005 01:20:12 -0800, "funfair" <abod_dana@hotmail.com> wrote:
[color=blue]
>help no one can know what is the problem
>please[/color]

Post the code and you might have more of a chance at getting replies.

Wayne Gillespie
Gosford NSW Australia
funfair
Guest
 
Posts: n/a
#4: Dec 31 '05

re: datepart problem in VB code


sorry
this is the code
thanks for replying
is it abug?

Private Sub Form_BeforeInsert(Cancel As Integer)
If IsNull(DMax("serial", "table_name")) Then
field = 2005000001
Else
If (DatePart("M", date) = "4" And DMax("REF_id", "table_name", "month =
4")) Then
field = DMax("serial", "table_name") + 1
Else
If (DatePart("M", date) = "4" And DMax("REF_id", "table_name", "month =
3 ")) Then
field = CLng(CStr(DatePart("yyyy", date)) & "000001")
Else
field = DMax("serial", "table_name") + 1
End If
End If
End If
another_field = CStr(Right(field, 6) & "/" & Left(field, 4))
End Sub

here first check if it null
then if its abeginning of finanical year and not the first time
increase max
but if its abeginning of finanical year and it is the first time
then just begin 1 on the year
else
complete auto numbering
it work correctly but when iam on a new year it complete
numbering

Closed Thread