Tempy wrote:
Hi Salad, thanks for the reply, but as a total newbie to this game i am
not sure how to do that. Could you explain.
Thanks in advance
Tempy
*** Sent via Developersdex http://www.developersdex.com ***
Sometimes I simply need a table that has only one record. The fields
may contain some counters and date fields. So...create a table called
Counters. Create a field called FormOpen and make it type Long. Save
it. Remember...1 record only. And make the default value 0. Open the
table and create a record for it and enter 0 in the counter field.
You could use an UpdateQuery to update the field in the OnOpen event of
the form, but I'll use code. In the form, drop a text box onto the
form. In the property sheet for the textbox, click on the Other tab
call it FormOpenedThisManyTimes.
Now open the property sheet for the form and in Events find OnOpen.
Click on the triple dot, select Code, and enter the following code
between the Sub/EndSub
Dim rst As DAO.Recordset
set rst = Currentdb.Openrecordset("Counters",dbopensnapshot)
rst.Edit
rst!FormOpen = rst!FormOpen + 1
Me.FormOpenedThisManyTimes = rst!FormOpen
rst.Update
rst.close
set rst = Nothing
You could also use an UpdateQuery to increment the counter and then use
DLookUp() to get the value but I figured some code would help you out
too. Highlight any words you don't understand...ex OpenRecordset and
press F1 for further help.