473,386 Members | 1,699 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,386 software developers and data experts.

Counters

Hi All,

I need some help with my counter, i've a database and the main table
is called PIRs. Initially i was using the code
=DMax("[pir id]","PIRs")+1 to increment the number which started at
about 362 that increamented fine on the form in a single user
environment.

When another user logged on the same number was given to both users
which we can't have as this would cause duplicates.

I was reading up about custom counters and saw a posting for the on
update where the number will update once the user saves the record.
Which is what i want.

This is the code that i have taken

rivate Sub PIR_ID_BeforeUpdate(Cancel As Integer)
If IsNull(Me.PIRs) Then
'Only make a number if it's a new record
me.PIR id=nz(dmax("[PIR ID]"."[PIRs]"))+1
Else
' do nothing: don't overwrite an existing VoucherNumber
End If
End Sub
But this does not work when i try and save the record it tells me that
it can't contain a null value blah blah blah.

Where exactly am i going wrong? I don't want a command box to show me
the number, i was access to automatically assign one once it's saved.

Thanks in advance

Carol

Sep 6 '07 #1
4 1487
ca**********@rbos.com wrote:
Hi All,

I need some help with my counter, i've a database and the main table
is called PIRs. Initially i was using the code
=DMax("[pir id]","PIRs")+1 to increment the number which started at
about 362 that increamented fine on the form in a single user
environment.

When another user logged on the same number was given to both users
which we can't have as this would cause duplicates.

I was reading up about custom counters and saw a posting for the on
update where the number will update once the user saves the record.
Which is what i want.

This is the code that i have taken

rivate Sub PIR_ID_BeforeUpdate(Cancel As Integer)
If IsNull(Me.PIRs) Then
'Only make a number if it's a new record
me.PIR id=nz(dmax("[PIR ID]"."[PIRs]"))+1
Else
' do nothing: don't overwrite an existing VoucherNumber
End If
End Sub
But this does not work when i try and save the record it tells me that
it can't contain a null value blah blah blah.

Where exactly am i going wrong? I don't want a command box to show me
the number, i was access to automatically assign one once it's saved.

Thanks in advance

Carol
Maybe change to
If Me.NewRecord then
me.[PIR id]=nz(dmax("[PIR ID]"."[PIRs]"))+1
'Save it
Me.Dirty = False
Endif
Sep 6 '07 #2
On Sep 6, 1:47 pm, Salad <o...@vinegar.comwrote:
carol.tay...@rbos.com wrote:
Hi All,
I need some help with my counter, i've a database and the main table
is called PIRs. Initially i was using the code
=DMax("[pir id]","PIRs")+1 to increment the number which started at
about 362 that increamented fine on the form in a single user
environment.
When another user logged on the same number was given to both users
which we can't have as this would cause duplicates.
I was reading up about custom counters and saw a posting for the on
update where the number will update once the user saves the record.
Which is what i want.
This is the code that i have taken
rivate Sub PIR_ID_BeforeUpdate(Cancel As Integer)
If IsNull(Me.PIRs) Then
'Only make a number if it's a new record
me.PIR id=nz(dmax("[PIR ID]"."[PIRs]"))+1
Else
' do nothing: don't overwrite an existing VoucherNumber
End If
End Sub
But this does not work when i try and save the record it tells me that
it can't contain a null value blah blah blah.
Where exactly am i going wrong? I don't want a command box to show me
the number, i was access to automatically assign one once it's saved.
Thanks in advance
Carol

Maybe change to
If Me.NewRecord then
me.[PIR id]=nz(dmax("[PIR ID]"."[PIRs]"))+1
'Save it
Me.Dirty = False
Endif- Hide quoted text -

- Show quoted text -
Hi,

Thanks for that i've changed it as suggested but when i try and save
it it gives me a complie error then goes back to highlighting the "."
in the code.
HRM not sure why.

Thanks
Carol

Sep 6 '07 #3
On Sep 6, 1:47 pm, Salad <o...@vinegar.comwrote:
carol.tay...@rbos.com wrote:
Hi All,
I need some help with my counter, i've a database and the main table
is called PIRs. Initially i was using the code
=DMax("[pir id]","PIRs")+1 to increment the number which started at
about 362 that increamented fine on the form in a single user
environment.
When another user logged on the same number was given to both users
which we can't have as this would cause duplicates.
I was reading up about custom counters and saw a posting for the on
update where the number will update once the user saves the record.
Which is what i want.
This is the code that i have taken
rivate Sub PIR_ID_BeforeUpdate(Cancel As Integer)
If IsNull(Me.PIRs) Then
'Only make a number if it's a new record
me.PIR id=nz(dmax("[PIR ID]"."[PIRs]"))+1
Else
' do nothing: don't overwrite an existing VoucherNumber
End If
End Sub
But this does not work when i try and save the record it tells me that
it can't contain a null value blah blah blah.
Where exactly am i going wrong? I don't want a command box to show me
the number, i was access to automatically assign one once it's saved.
Thanks in advance
Carol

Maybe change to
If Me.NewRecord then
me.[PIR id]=nz(dmax("[PIR ID]"."[PIRs]"))+1
'Save it
Me.Dirty = False
Endif- Hide quoted text -

- Show quoted text -
Sorry Ignore the last comment, HRM, well i changed it to the above but
when i click to save the record it still tells me that it can not
contain a null value.......

Sep 6 '07 #4
ca**********@rbos.com wrote:
On Sep 6, 1:47 pm, Salad <o...@vinegar.comwrote:
>>carol.tay...@rbos.com wrote:
>>>Hi All,
>>>I need some help with my counter, i've a database and the main table
is called PIRs. Initially i was using the code
=DMax("[pir id]","PIRs")+1 to increment the number which started at
about 362 that increamented fine on the form in a single user
environment.
>>>When another user logged on the same number was given to both users
which we can't have as this would cause duplicates.
>>>I was reading up about custom counters and saw a posting for the on
update where the number will update once the user saves the record.
Which is what i want.
>>>This is the code that i have taken
>>>rivate Sub PIR_ID_BeforeUpdate(Cancel As Integer)
If IsNull(Me.PIRs) Then
'Only make a number if it's a new record
me.PIR id=nz(dmax("[PIR ID]"."[PIRs]"))+1
Else
' do nothing: don't overwrite an existing VoucherNumber
>> End If
>> End Sub
But this does not work when i try and save the record it tells me that
it can't contain a null value blah blah blah.
>>>Where exactly am i going wrong? I don't want a command box to show me
the number, i was access to automatically assign one once it's saved.
>>>Thanks in advance
>>>Carol

Maybe change to
If Me.NewRecord then
me.[PIR id]=nz(dmax("[PIR ID]"."[PIRs]"))+1
'Save it
Me.Dirty = False
Endif- Hide quoted text -

- Show quoted text -


Sorry Ignore the last comment, HRM, well i changed it to the above but
when i click to save the record it still tells me that it can not
contain a null value.......
Go to the debug window and enter
? nz(dmax("[PIR ID]"."[PIRs]"))+1

Looking at it, it might be that
? nz(dmax("[PIR ID]","PIRs"))+1
should work
Sep 6 '07 #5

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

Similar topics

2
by: David Mitchell | last post by:
Hello group, I'm trying to write code to test an application we're developing. This application needs to store its own performance data in the registry, and we'd like to be storing quite a...
9
by: Carlos | last post by:
I'm responsible for the content in a call center's intranet site. There are approximately 600 pages on 7 sub-webs. I have access to the sub-webs, but I don't have access to the root web or web...
0
by: rob_c | last post by:
Hi, I've been working with the EIF for a few days now. One of the default event sinks provided is the WMI. I've played around a bit and can send events to the WMI. My question here centers on...
2
by: Don | last post by:
Hello! I am trying to write some code to access performance counters on a remote machine. Ideally, I would like to add a machine to a tree control (like the "Servers" view in the .NET IDE) and...
4
by: Chad Myers | last post by:
I'm instrumenting my app with a few performance counters and I'd like to ask you all for some advice on how to handle performance counter instances. I have a class library that is a base library...
0
by: Christopher Attard | last post by:
Hi, I need to create a dialog like the 'Add Counters' dialog box in perfmon. I'm using the System.Diagnostics namespace class in .NET and I've managed to do it. The problem arises when I'm...
1
by: db | last post by:
Hello, I am writing a utility to get the performance counters from a remote machine. Currently, I am usign the System.Diagnostics.PerformanceCounter class to retrieve these counters, but they...
7
by: James | last post by:
Hi Has anybody had any experience of ASP.Net performance counters not updating. In the performance monitor application when I try to add the groups ASP.NET and ASP.NET Applications the...
0
by: JackC | last post by:
Hi, We have an ASP.NET application with a (kinda shady) COM component that we don't know much about and don't have responsability for. But you know how it is - if the app. goes down its my fault...
10
by: Zytan | last post by:
I made a program using the Timer class, and I start the timer with Timer.Start(), but don't stop it with Timer.Stop(), and I assumed this was ok, but, Process Explorer informs me, after running it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
jinu1996
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 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.