Getting a number to update

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

Guest

I have a form with a button that when clicked I would like to have it go to a
file, get the number there, add one to it, and then save it back in that file
as well as display it in the field on the form. I created a table for this
number, but don't know how to program the button to do what I want it to do.
The users need a new number only some of the time, and would then click the
button. The number needs to be incremental by one. Would a query work best
or an update? I am at a loss, please help.

Thanks,
 
First BackUp your data

I assume that this table has only one record which you are trying to update
(with no criteria), if that the case you can try something like

Dim MyNum As Double
' Get the field value
MyNum = DLookup("[MyNum]", "[TableName]")
' Update the table, add 1
CurrentDb.Execute ("Update TableName Set MyNum=" & MyNum + 1),dbFailOnError
' Display the value in the form
Me.[TextBoxName] = MyNum + 1

Again - This SQL will update all the records in that table, there is no
criteria in it
 
Back
Top