473,324 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

datepart problem in VB code

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?

Dec 28 '05 #1
3 2270
help no one can know what is the problem
please

Dec 30 '05 #2
On 30 Dec 2005 01:20:12 -0800, "funfair" <ab*******@hotmail.com> wrote:
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
Dec 30 '05 #3
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

Dec 31 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David | last post by:
Hi Group, i am trying to use the DatePart function on my SQL2000 database. I have a table called visitors with a field called DateTimeEntrance which is filled everytime a visitor enters the site....
2
by: Tipple | last post by:
I'm trying to increment between the end of lunch and the end of the day. The code below is returning a datePart of 13 instead of 1 (for 1:00:00 PM) and 14 instead of 2:00:00 PM etc.. If...
2
by: sdowney717 | last post by:
The field itemdate is a datetime field in sqlserver2000 DB This works fine: Select Id From BookData Where (MONTH(itemdate) = '01') and (DAY(itemdate) = '02') and (YEAR(itemdate) = '2005') order...
2
by: Aaran76 | last post by:
I am creating a booking system in ASP.Net with VB and a MSSQL backend. I am having problems knowing where to begin with a particular part of the system. Bookings can only be made in weekly...
3
by: S. van Beek | last post by:
Dear reader, With DatePart() you can subtract the year or the week from a date field with: DatePart("yyyy";) for the year
2
by: le0 | last post by:
Hello guys, Is there anything wrong with my code (see below) bcoz when 10p-6a shift my browser returns the error cannot be a zero-length string. Im wondering why, bcoz the 2 other shift works...
10
by: Mika M | last post by:
Hi! I'm converting some methods of VB-class into C#-class for another project. It's quite easy, but when converting method which returns last week number of the entered year I got problems. The...
1
by: Spoogledrummer | last post by:
Hi, I've run across a problem with on one of the applications I work on. A report uses the group by datepart (wk,Date) but as this is 2007 it messes up as it sees there being 53 weeks so breaks a...
3
by: grabit | last post by:
Hi Peoples I am having probs with the datepart function with a query.What i want is to get all listings made in any month in any year ie May 2007 i have 2 drop down boxes to select the listedmonth...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.