Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2007

Tip: Looking for answers? Try searching our database.

Create form button to add 1 to field value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JimboJones - 13 May 2007 19:34 GMT
What I am trying to do is create a simple button that will +1 to the value of
a field.
Say for instance, record 1 has field "pens" and value 10... i want a simple
button that will change that to 11, then 12 if clicked again.

Thanks in advance
Jeff @ CI - 13 May 2007 20:57 GMT
Jimbo, this is a question I was going to post also.  However I tried a few
things and had limited success with this process.  If anyone else has any
better ideas, I would like to know also.

I created a blank button.  In the Properties, I clicked on the event tab and
then located the OnClick property.  I created an event procedure as follows:

Private Sub Command109_Click()
On Error GoTo Err_Command109_Click

   [Feild to update] = [Field to update] + 1

Exit_Command109_Click:
   Exit Sub

Err_Command109_Click:
   MsgBox Err.Description
   Resume Exit_Command109_Click
   
End Sub

This worked in the couple of tests that I conducted.  I also suggest that if
your form is similar in function to mine, that you create another button that
allows you to minus the field value as you need.

Again, if anyone else has any better ways to handle this, I am interested
also.

Jeff

> What I am trying to do is create a simple button that will +1 to the value of
> a field.
> Say for instance, record 1 has field "pens" and value 10... i want a simple
> button that will change that to 11, then 12 if clicked again.
>
> Thanks in advance
missinglinq - 13 May 2007 20:59 GMT
Private Sub ButtonToIncrementPensField_Click()
  Me.Pens = Me.Pens + 1
End Sub

Signature

There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

JimboJones - 13 May 2007 21:24 GMT
Many thanks.. that works perfectly in 2007, thanks :)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.