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
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.
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) - Private Sub Entry_Number_DblClick(Cancel As Integer)
-
Me.Entry_Number = Val(Left(Me.Entry_Number, 5) + 1)
-
DoCmd.RunCommand acCmdSaveRecord
-
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: - Private Sub Entry_Number_GotFocus()
-
Me.Entry_Number = DMax(Val([Entry_Number], “AccountTransactions”)) + 1
-
End Sub
But, I get Compile error: Wrong number of arguments or invalid property assignment.
What am I doing wrong?
nico5038 3,080
Recognized Expert Specialist
You need to change the code to: - Private Sub Entry_Number_GotFocus()
-
Me.Entry_Number = DMax("Val([Entry_Number]", “AccountTransactions”)) + 1
-
End Sub
Or better: - Private Sub Entry_Number_GotFocus()
-
Me.Entry_Number = NZ(DMax("Val([Entry_Number]", “AccountTransactions”)),0) + 1
-
End Sub
To make sure that an empty table works too.
Personally I prefer to put this code in the OnInsert Event...
Nic;o)
You need to change the code to: - Private Sub Entry_Number_GotFocus()
-
Me.Entry_Number = DMax("Val([Entry_Number]", “AccountTransactions”)) + 1
-
End Sub
Or better: - Private Sub Entry_Number_GotFocus()
-
Me.Entry_Number = NZ(DMax("Val([Entry_Number]", “AccountTransactions”)),0) + 1
-
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??
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
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
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)
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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: 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...
|
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: 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: 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,...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |