Tags: access, database, field, fields, form, imwanting, increase, increasing, incremental, linked, microsoft, mysql, number, numeric, oracle, sql, table, thats, value

Incremental increasing a Fields numeric value

On Database » Microsoft Access

3,234 words with 3 Comments; publish: Wed, 04 Jun 2008 03:04:00 GMT; (25050.78, « »)

Hi,

I have a field on a form that's linked to a Number field in a Table that I'm

wanting to increase the numeric value in that field by one(1), everytime a

button is clicked on the Form. So, if a User clicked the button five times

then the number 5 will show in the table. I can easily get the the table to

show the number one - first click using a Toggle Button, but don't know how

get the field to increase each time the button is clicked.

Thanks,

Larry

All Comments

Leave a comment...

  • 3 Comments
    • Put something like this in the On Click event of your button.

      Dim db As Database

      Dim rst As Recordset

      Set db = CurrentDb()

      Set rst = db.OpenRecordset("tblsettings", dbOpenDynaset)

      With rst

      .Edit

      .("MyFieldf") = .("MyField") + 1

      .Update

      End With

      "Larry" wrote:

      > Hi,

      > I have a field on a form that's linked to a Number field in a Table that I'm

      > wanting to increase the numeric value in that field by one(1), everytime a

      > button is clicked on the Form. So, if a User clicked the button five times

      > then the number 5 will show in the table. I can easily get the the table to

      > show the number one - first click using a Toggle Button, but don't know how

      > get the field to increase each time the button is clicked.

      > Thanks,

      > Larry

      #1; Wed, 04 Jun 2008 03:06:00 GMT
    • Larry -

      This may work for you: In the OnClick Event of the button,

      DoCmd.SetWarnings False

      DoCmd.RunSQL "UPDATE table_name SET count = count +1 WHERE some

      condition is true"

      DoCmd.SetWarnings True

      This will add one to the count in the table every time the button is clicked

      without the user knowing that it happens

      "Larry" wrote:

      > Hi,

      > I have a field on a form that's linked to a Number field in a Table that I'm

      > wanting to increase the numeric value in that field by one(1), everytime a

      > button is clicked on the Form. So, if a User clicked the button five times

      > then the number 5 will show in the table. I can easily get the the table to

      > show the number one - first click using a Toggle Button, but don't know how

      > get the field to increase each time the button is clicked.

      > Thanks,

      > Larry

      #2; Wed, 04 Jun 2008 03:06:00 GMT
    • Hi Klatuu,

      My code looks like this but it hangs on the first line - no telling what

      else is worng with it - I know I'm suppose to sub some stuff into what you've

      given me but I don't know where or what.

      Private Sub Opt_Tot_Obsrv_One_Click()

      Dim db As Database

      Dim rst As Recordset

      Set db = CurrentDb()

      Set rst = db.OpenRecordset("tblsettings", dbOpenDynaset)

      With rst

      .Edit

      .Txt_T_Obsr_One_Calc = Txt_Tot_Observ_One + 1

      .Update

      End With

      End Sub

      "Klatuu" wrote:

      [vbcol=seagreen]

      > Put something like this in the On Click event of your button.

      > Dim db As Database

      > Dim rst As Recordset

      > Set db = CurrentDb()

      > Set rst = db.OpenRecordset("tblsettings", dbOpenDynaset)

      > With rst

      > .Edit

      > .("MyFieldf") = .("MyField") + 1

      > .Update

      > End With

      >

      > "Larry" wrote:

      #3; Wed, 04 Jun 2008 03:07:00 GMT