473,503 Members | 2,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Increase value by 1

4 New Member
Hi. I am fairly new at Access and am in need of some help...

I am trying to use the database located here:
http://office.microsoft.com/en-us/te...CT101428241033

On the form Account Transaction List I would like for the Entry Number field to start with 08001 and then increase by 1 for each new entry.

How do I make this possible?

thx

tela
Oct 30 '08 #1
9 14033
NeoPa
32,557 Recognized Expert Moderator MVP
Tela,

We are going to need to see your question posted in here. No-one wants to go searching out, or linking across, to find out what your question means.

It needs to be expressed in the thread, clearly.
Oct 30 '08 #2
nico5038
3,080 Recognized Expert Specialist
You'll need to create your own function to create the needed increment.
A sample can be found at: http://bytes.com/topic/access/answer...umber-question

Nic;o)
Oct 31 '08 #3
prncstela
4 New Member
Tela,

We are going to need to see your question posted in here. No-one wants to go searching out, or linking across, to find out what your question means.

It needs to be expressed in the thread, clearly.
Ok... sorry about that.

Right now I have (thanks to Nico's post)
Expand|Select|Wrap|Line Numbers
  1. Private Sub Entry_Number_DblClick(Cancel As Integer)
  2. Me.Entry_Number = Val(Left(Me.Entry_Number, 5) + 1)
  3. DoCmd.RunCommand acCmdSaveRecord
  4. End Sub
So, when I double click the Entry Number field on the Account Transaction List form it increases what is currently in the field by 1 each time it is double clicked (so, I could do it all day and it would +1 each time). Also, there isn't anything in the Entry Number field when I start a new record so I get Run-time error '94': Invalid use of Null.

What I would like is after I click New Entry the Entry Number field takes the highest value from the Account Transactions table(Entry Number field) and +1.

After looking around I found a code and tried to tailor it to what I need and came up with this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Entry_Number_GotFocus()
  2. Me.Entry_Number = DMax(Val([Entry_Number], “AccountTransactions”)) + 1
  3. End Sub
But, I get Compile error: Wrong number of arguments or invalid property assignment.

What am I doing wrong?
Nov 1 '08 #4
nico5038
3,080 Recognized Expert Specialist
You need to change the code to:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Entry_Number_GotFocus()
  2. Me.Entry_Number = DMax("Val([Entry_Number]", “AccountTransactions”)) + 1
  3. End Sub
Or better:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Entry_Number_GotFocus()
  2. Me.Entry_Number = NZ(DMax("Val([Entry_Number]", “AccountTransactions”)),0) + 1
  3. End Sub
To make sure that an empty table works too.
Personally I prefer to put this code in the OnInsert Event...

Nic;o)
Nov 1 '08 #5
prncstela
4 New Member
You need to change the code to:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Entry_Number_GotFocus()
  2. Me.Entry_Number = DMax("Val([Entry_Number]", “AccountTransactions”)) + 1
  3. End Sub
Or better:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Entry_Number_GotFocus()
  2. Me.Entry_Number = NZ(DMax("Val([Entry_Number]", “AccountTransactions”)),0) + 1
  3. End Sub
To make sure that an empty table works too.
Personally I prefer to put this code in the OnInsert Event...

Nic;o)
Thanks, Nico. With the code you suggested I'm getting a Compile error: Expected: end of statement

Any ideas??
Nov 1 '08 #6
nico5038
3,080 Recognized Expert Specialist
Oops, overlooked theclosing ')' in your Val() function, try:
Me.Entry_Number = NZ(DMax("Val([Entry_Number])", “AccountTransactions”)),0) + 1
Nov 1 '08 #7
prncstela
4 New Member
Oops, overlooked theclosing ')' in your Val() function, try:
Me.Entry_Number = NZ(DMax("Val([Entry_Number])", “AccountTransactions”)),0) + 1
I am now receiving a syntax error? I apologize for being a pain.

Also, does it matter if I am putting this on the VBA for the form or the table? I am putting it in the one for the table (wasn't sure if that made a difference).t
Nov 1 '08 #8
nico5038
3,080 Recognized Expert Specialist
I am now receiving a syntax error? I apologize for being a pain.

Also, does it matter if I am putting this on the VBA for the form or the table? I am putting it in the one for the table (wasn't sure if that made a difference).t
Try:
Me.Entry_Number = NZ(DMax("Val([Entry_Number])", “AccountTransactions”),0) + 1

Nic;o)
Nov 2 '08 #9
NeoPa
32,557 Recognized Expert Moderator MVP
Nico,

What you missed there I think is the fact that the double-quotes (") characters you're using are not!

If you look at AccountTransactions - you will see they are special characters, presumably from a word-processor, rather than the actual (") character itself.
Nov 2 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2141
by: Miguel Dias Moura | last post by:
Hello, I have a dataset (users) on an ASP.NET/VB page (detail.aspx). A record on this dataset (users) has 3 fields: "id", "username", "visits". The page detail.aspx is called with a...
3
2365
by: Shapper | last post by:
Hello, I have a database table with 2 fields: and ; I need to create a function which increases by 1 the number in field for a certain id. In this moment I have the following: Private...
3
3570
by: Edwin New | last post by:
I need to increase the number of connections to PostgreSQL 7.2.1. I have tried changing the value of max_connections in Postgresql.conf. It was commented out (as are all other entries except...
2
3830
by: msnews.microsoft.com | last post by:
Hi all I am working on an application for a touch screen terminal. I have placed a datagrid on the form and the user will select a row on the datagrid. I have increased the font size on the...
5
19285
by: ipy2006 | last post by:
Hi All: In the table XYZ.ORD_DTL the column PDT_DESC is CHAR(35). I want to increase it to CHAR(100). However, I am getting the following error. Please help! db2 =alter table XYZ.ORD_DTL alter...
4
58437
by: =?Utf-8?B?c2FtZWVy?= | last post by:
environment : .net framework 1.1, ado.net, visual studio 2003, vb, sqlsever 2000, winforms, webforms I want to increase the timout of the webservice in the application which is being used in a...
0
1587
by: herre | last post by:
I wonder if there is a sql command or another way to increase sequence value more than one without modify de increment value of the sequence. I have to do that because in some problems i need to...
3
2924
by: nineoo | last post by:
To all, Ok , now this may sound a little crazy, but does any one know if there is a way to increase the maximum value of a unsigned long int? I'm aware of the the max value of an...
1
2801
by: Victor Hadianto | last post by:
Hi, I have a WPF ScrollBar that had a rather large maximum value. Now the problem is that everytime I click the RepeatButton (the buttons on both side of the Thumb button) it only increases the...
4
4831
by: zoeb | last post by:
Hi. I have a form which the user enters 2 years worth of data into (one record per year). The aim, is to populate the table this form is based on with 3 more years worth of data (i.e. creating 3...
0
7204
marktang
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,...
0
7091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
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
7464
tracyyun
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...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.