Incremental increasing a Fields numeric value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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 -

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
 
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
 
Back
Top