Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / December 2005

Tip: Looking for answers? Try searching our database.

datepart problem in VB code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
funfair - 28 Dec 2005 18:46 GMT
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 - 30 Dec 2005 09:20 GMT
help no one can know what is the problem  
please
Wayne Gillespie - 30 Dec 2005 09:25 GMT
>help no one can know what is the problem  
>please

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

Wayne Gillespie
Gosford NSW Australia
funfair - 31 Dec 2005 14:38 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.