I may just be dumb, but does anyone know how to change values in the database with buttons on forms. In my situation i will just want to + or - 1 to the values that are in there already.
Sorry if i am being really dumb guys!
Thanks
I may just be dumb, but does anyone know how to change values in the database with buttons on forms. In my situation i will just want to + or - 1 to the values that are in there already.
Sorry if i am being really dumb guys!
Thanks
Let's say that your command button was named Command9, and the field you want to update is Field1.
Then add this VBA code to the Click event of the command button to add one to Field1 every time it is clicked.
Code:Private Sub Command9_Click() Me.Field1 = Me.Field1 + 1 End Sub
Hi, ^^ thank you. But when i run this code
Private Sub Command0_Click()
Me.Field2 = Me.Field2 + 1
End Sub
it gives me this: "compile error: Method or data member not found."
This is in access 2016 if it changes anything.
Is Field2 the name of your Field?
Is it bound to anything?
What data type is it?
Hi,
Whilst i have been doing this it is.
I dont think that it is.
It is a Number.
Are you showing Field2 on your Form?
If it is not bound to anything, does it have any initial value (if so, where is it being set)?
ah ^^, thank you showing field 2 fixed it![]()
Yes, the "Me" reference only works if the field is on the Form.
Note if you want to hide it from view, just change the Visible property for that field to No.