I am trying to get job numbers to reset to 000 at begining of each
month
and beginning of new year
I was able to do this on another form just resetting at beginning of
year now
i need to do the same on this form with month
this is what i have right now on before update event
If IsNull(Me!JobNo1) Then
Me!JobNo1 = Nz(DMax("[JobNo1]", "[jobs]") + 1, "EntrDate >=
DateSerial(Year(Date(),1,1), Month(Date()),1,1)")
End If
my result should be ymm-000
at beginning of each month and year
I am getting the correct ymm but getting highest number +1 instead of
000
This is what I used on other for that works
If IsNull(Me!ResponseNo) Then
Me!ResponseNo = Nz(DMax("[ResponseNo]", "[tblRepair]", "DateEntered
>=DateSerial(Year(Date()),1,1)"), 0) + 1
I really appreceate any help and input on this
Ken 9 1588
ken wrote:
I am trying to get job numbers to reset to 000 at begining of each
month
and beginning of new year
I was able to do this on another form just resetting at beginning of
year now
i need to do the same on this form with month
this is what i have right now on before update event
If IsNull(Me!JobNo1) Then
Me!JobNo1 = Nz(DMax("[JobNo1]", "[jobs]") + 1, "EntrDate >=
DateSerial(Year(Date(),1,1), Month(Date()),1,1)")
End If
my result should be ymm-000
at beginning of each month and year
I am getting the correct ymm but getting highest number +1 instead of
000
This is what I used on other for that works
If IsNull(Me!ResponseNo) Then
Me!ResponseNo = Nz(DMax("[ResponseNo]", "[tblRepair]", "DateEntered
=DateSerial(Year(Date()),1,1)"), 0) + 1
I really appreceate any help and input on this
Ken
ken wrote:
I am trying to get job numbers to reset to 000 at begining of each
month
and beginning of new year
I was able to do this on another form just resetting at beginning of
year now
i need to do the same on this form with month
this is what i have right now on before update event
If IsNull(Me!JobNo1) Then
Me!JobNo1 = Nz(DMax("[JobNo1]", "[jobs]") + 1, "EntrDate >=
DateSerial(Year(Date(),1,1), Month(Date()),1,1)")
End If
my result should be ymm-000
at beginning of each month and year
I am getting the correct ymm but getting highest number +1 instead of
000
This is what I used on other for that works
If IsNull(Me!ResponseNo) Then
Me!ResponseNo = Nz(DMax("[ResponseNo]", "[tblRepair]", "DateEntered
=DateSerial(Year(Date()),1,1)"), 0) + 1
I really appreceate any help and input on this
Ken
Your syntax is all messed up here. The plus 1 goes at the end just like it is
on the expression you say is working. Also the where clause with DateSerial as
you have it written makes no sense. Try the following...
Me!JobNo1 = Nz(DMax("[JobNo1]", "[jobs]", "EntrDate >= DateSerial(Year(Date()),
Month(Date()), 1)"), 0) + 1
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Now that I have this number working in the form
what would be the best approach to get the
ymm-000 number back to the jobs table
so I can use this as the primary key
some thing like after update
jobs.JobNumber=Me!JobNumber?
Thanks
Ken
ken wrote:
Now that I have this number working in the form
what would be the best approach to get the
ymm-000 number back to the jobs table
so I can use this as the primary key
some thing like after update
jobs.JobNumber=Me!JobNumber?
Thanks
Ken
Personally I wouldn't do that. I would use a composite PK consisting of the
date and Max()+1 number or I would use a surrogate like AutoNumber for the PK.
If you insist on saving it to the table then doing what you are suggesting in
the BeforeUpdate of the form should accomplish it. Just add that line after the
lines that you already have to calculate the Max()+1 value.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Rick Brandt wrote:
ken wrote:
Now that I have this number working in the form
what would be the best approach to get the
ymm-000 number back to the jobs table
so I can use this as the primary key
some thing like after update
jobs.JobNumber=Me!JobNumber?
Thanks
Ken
Personally I wouldn't do that. I would use a composite PK consisting of the
date and Max()+1 number or I would use a surrogate like AutoNumber for the PK.
If you insist on saving it to the table then doing what you are suggesting in
the BeforeUpdate of the form should accomplish it. Just add that line after the
lines that you already have to calculate the Max()+1 value.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
well after playing with this for a while decided I would like the
JobNumber to be primary key in table as it matches what I had before
and all other tables use this number
I already have about 9000 records with this number in database from the
old way
of changing first three numbers manually every month
Just trying to make this better
When i put jobs.JobNumber=Me!JobNumberin before update on form it
does not update table
thanks for any advice
JobNumber is in query as expression JobNumber:
Right(Format([EntrDate],"yyyy"),1) & Format([EntrDate],"mm") & "-" &
Format([JobNo1],"000")
"ken" <ke******@yahoo.comwrote in
news:11**********************@e3g2000cwe.googlegro ups.com:
I am trying to get job numbers to reset to 000 at begining of
each month
and beginning of new year
I was able to do this on another form just resetting at
beginning of year now
i need to do the same on this form with month
this is what i have right now on before update event
If IsNull(Me!JobNo1) Then
Me!JobNo1 = Nz(DMax("[JobNo1]", "[jobs]") + 1, "EntrDate
>=
DateSerial(Year(Date(),1,1), Month(Date()),1,1)")
End If
my result should be ymm-000
at beginning of each month and year
I am getting the correct ymm but getting highest number +1
instead of 000
That ymm-000+1 is because your field is text and not numeric. It
worked in your previous example because you were adding a number
to a number.
>
This is what I used on other for that works
If IsNull(Me!ResponseNo) Then
Me!ResponseNo = Nz(DMax("[ResponseNo]", "[tblRepair]",
"DateEntered
>>=DateSerial(Year(Date()),1,1)"), 0) + 1
I really appreceate any help and input on this
Ken
what you want to do is get the current number, grab the fifth
through seventh characters, convert to a number, add 1 and
reassemble the string.
iNewJobNo = _
Nz(cint(DMax("mid([JobNo1],5,7))", _
"[jobs]", _
"EntrDate >= DateSerial(Year(Date(),1,1), _
& "Month(Date()),1,1),0) + 1
If IsNull(Me!JobNo1) Then
me!jobNo1 = _
Right(Format([EntrDate],"yyyy"),1) _
& Format([EntrDate],"mm") _
& "-" & Format([iNewJobNo],"000")
end if
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com
Me!JobNo1 = Nz(DMax("[JobNo1]", "[jobs]", "EntrDate >=
DateSerial(Year(Date()),
Month(Date()), 1)"), 0) + 1
seemed to work good in form
JobNo1=001
JobNumber=610-001
now I need to get JobNumber to populate table for primary Key
Thanks
Ken
ken wrote:
Rick Brandt wrote:
>ken wrote:
>>Now that I have this number working in the form what would be the best approach to get the ymm-000 number back to the jobs table so I can use this as the primary key some thing like after update jobs.JobNumber=Me!JobNumber? Thanks Ken
Personally I wouldn't do that. I would use a composite PK consisting of the date and Max()+1 number or I would use a surrogate like AutoNumber for the PK.
If you insist on saving it to the table then doing what you are suggesting in the BeforeUpdate of the form should accomplish it. Just add that line after the lines that you already have to calculate the Max()+1 value.
-- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com
well after playing with this for a while decided I would like the
JobNumber to be primary key in table as it matches what I had before
and all other tables use this number
I already have about 9000 records with this number in database from
the old way
of changing first three numbers manually every month
Just trying to make this better
When i put jobs.JobNumber=Me!JobNumberin before update on form it
does not update table
thanks for any advice
JobNumber is in query as expression JobNumber:
Right(Format([EntrDate],"yyyy"),1) & Format([EntrDate],"mm") & "-" &
Format([JobNo1],"000")
You cannot set the value of a field based on an expression. You need to set
the value of the base fields that are used in the expression and you are
already doing that. This was exaclty my point, that if you can use an
expression then you do not need a "saved field" containing the same data.
If you must have it saved as a separate field in your table then it is THAT
field that you must set in the BeforeUpdate event, not the one based on an
expression.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Stewart Allen |
last post by:
Hi there
I'm trying to find part serial numbers between 2 numbers. The user selects a
part number from a combo box and then enters a range of serial numbers into
2 text boxes and the resulting...
|
by: hartley_aaron |
last post by:
Hi,
I was trying to blank out (null out?) a field of a record that is a
date/time data type. Here is code excerpt:
Dim D As Database
Dim rsRacks As Recordset
Dim strSQL As String
strSQL...
|
by: Al the programmer |
last post by:
I need to access the serial ports on my webserver from an asp.net page. I
have no problem accessing the serial ports from a windows form application,
but the code doesn't work in asp.net. I have...
|
by: Daniel Kaseman |
last post by:
How do I convert a date into a serial number?
(I'm trying to enter a FROM date and a TO date, then make my PROGRESS BAR
show how close I am to the TO date.) get it?
I know that MS Excel...
|
by: sam |
last post by:
Possible convert VB 6 to VB.Net 1.1 for date serial function?
Example, Calendar_Date = DateSerial(1900+(Julian_Date/1000), 1,Julian_Date
Mod 1000) ?
Calendar_Date and Julian_Date are input...
|
by: Glencannon4424 via AccessMonster.com |
last post by:
Hello,
I have what I believe amounts to a Date Serial issue. I have the following
columns in my table:
Hire-Date
Hire-Year
WTD-RATE
Wks-in-Yr
|
by: Peter |
last post by:
What is the easiest way to convert serialdate (like excel has) into real
date in VB.NET?
Thank You
Peter
|
by: scolivas |
last post by:
Hi all, I have a situation that is requiring me to make an Entry Date part of the Primary Key. Problem I am having is that it includes the time too.
What I have is an inventory return table.
It...
|
by: terry |
last post by:
Hi,
I am trying to send a character to '/dev/ttyS0' and expect the same
character and upon receipt I want to send another character. I tired
with Pyserial but in vain.
Test Set up:
1. Send...
|
by: peeaurjee |
last post by:
Hello,
I have a query containing Serial, Name, Residence Visa Expiry Date in MS Access 2003. I need to put Residence Visa Registration Date in other field and that would be in reverse I mean 3...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
| |