I have a database that is just an advanced lookup for prices. When a user
enters the part number it launches a new form with the price and the current
inventory. My users aren't familiar with access as a result aren't using the
database. My boss has asked me to add a counter just to count the number of
times that the Price/Inventory form is launched. I know that there is going
to be some easy coding for this, but I'm not familiar with writing VB code.
Becuase I have had some coding experience I can read it and alter to a
certain extent. My thought is that it will be something like this.
Text box on the form with a number in it (tboCounter), set so that it is not
visible.
OnLaunch - tboCounter=tboCounter+1
something like that. I know its really basic but any help would be greatly
appreciated.
Patrick
Klatuu - 20 May 2008 19:28 GMT
OnLaunch would actually be the form Load event. You idea would work well for
the current session, but as soon as you close the form, the value will be
lost.
What you need is a table to store the counter in.
I would suggest you create a one field table and that field be identified as
a Numeric Long Integer data type and a default value of 0.
Then create a query that updates the table with the current value of the
table + 1.
Then run the query in the form's load event. It would be just one line like
this:
Currentdb.Execute "NameOfQuery", dbFailOnError

Signature
Dave Hargis, Microsoft Access MVP
> I have a database that is just an advanced lookup for prices. When a user
> enters the part number it launches a new form with the price and the current
[quoted text clipped - 14 lines]
>
> Patrick
fredg - 20 May 2008 19:48 GMT
> I have a database that is just an advanced lookup for prices. When a user
> enters the part number it launches a new form with the price and the current
[quoted text clipped - 14 lines]
>
> Patrick
Here is one way.
Create a new table.
Add 1 Field "CountTimes" Number datatype, Field Size Long Integer.
Name the table "tblCountOpen"
Set the field value of just the first record to 0.
Code the Form's Open Event:
CurrentDb.Execute "Update tblCountOpen set tblCountOpen.CountTimes =
CountTimes + 1;", dbFailOnError
Then you can read the value from any form in the database, including
the one you are counting, using an unbound text control:
=DLookUp("[CountTimes]","tblCountOpen")

Signature
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
pfm721 - 21 May 2008 14:50 GMT
Thanks for the help. Just what I was looking for.
> > I have a database that is just an advanced lookup for prices. When a user
> > enters the part number it launches a new form with the price and the current
[quoted text clipped - 28 lines]
> the one you are counting, using an unbound text control:
> =DLookUp("[CountTimes]","tblCountOpen")