473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Number of times database opened

Good day,

Is it possible to indicate on a form how many times the open database
has been opened/viewed.

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #1
10 1719
Tempy wrote:
Good day,

Is it possible to indicate on a form how many times the open database
has been opened/viewed.

Tempy

*** Sent via Developersdex http://www.developersdex.com ***

Sure. Create a table to store a counter. In the form's OnOpen event
update the table to increment the field by 1. Then put a text box on
the form to display that counter.
Nov 13 '05 #2
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 ***
Nov 13 '05 #3
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.
Nov 13 '05 #4
Hi Salad,

thank you so much for the clear explanation, it is much appreciated.

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #5
Hi Salad,

I tried the code and i get the following error:
Compile error: User-defined type not defined

Please help !

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #6
When you are entering the code you need to make sure you have gone to
the Tools menu and selected References.

These are all the command libraries that you might need. The fact that
the code supplied uses a DAO call means that you need the DAO library
to enable those commands and functions.

Look in the list presented by the References menu option for Microsoft
DAO 3.xx Object Library.

It will be either 3.51, 3.6 or if you are using an older version of
access, it could be 2.5.

Select ONE of these and click OK.

Then recompile the code and save it then close the visual basic window.

Now try your code out for size... it should work perfectly!

Good luck, let us know how you get on.

Rob.

Nov 13 '05 #7
Tempy wrote:
Hi Salad,

I tried the code and i get the following error:
Compile error: User-defined type not defined

Please help !

Tempy

*** Sent via Developersdex http://www.developersdex.com ***


Please change the line
Set rst = CurrentDb.OpenRecordset("Counters", dbOpenSnapshot)
to
Set rst = CurrentDb.OpenRecordset("Counters", dbOpenDynaset)
endif

Does your FormOpen even look like this (excluding any additional sruff
you added)

Private Sub Form_Open(Cancel As Integer)
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("Counters", dbOpenDynaset)
rst.Edit
rst!FormOpen = rst!FormOpen + 1
Me.FormOpenedThisManyTimes = rst!FormOpen
rst.Update
rst.Close
Set rst = Nothing
End Sub

Do you have a table called Counters? Does it contain a field called
FormOpen? Is it a number?

Does you form have a textbox named FormOpenedThisManyTimes

If all things are in place, this works for me.
Nov 13 '05 #8
Hi Salad & Rob, Thank you both it is now working, using both your fixes.
I am very new to this game, but enjoy it. Are there any other references
that i should have selected ?
I am sorry for the time delay but when you are working i am sleeping !!
(In South Africa)needless to say it frustrates the hell out of me !!

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #9
Tempy wrote:
Hi Salad & Rob, Thank you both it is now working, using both your fixes.
I am very new to this game, but enjoy it. Are there any other references
that i should have selected ?
I am sorry for the time delay but when you are working i am sleeping !!
(In South Africa)needless to say it frustrates the hell out of me !!

Tempy

*** Sent via Developersdex http://www.developersdex.com ***


My reference list is quite minimal in Access 97....
VBA
Access Object Library
DAO 3.51
in that order. Sometimes the order of the reference list is quite
important. In Access 2000+, the DA0 is 3.6.

You might want to check Albert's site. I think he has some discussions
somewhere on binding (applicable to references) that would be of interest.
http://www.members.shaw.ca/AlbertKallal

Search also for messages from Allen Browne and Tony Toews in this
newsgroup. They have links to their websites chock full of good
stuff...maybe links to other web pages of the regulars here.

And of course http://www.mvps.org/Access has a good stock of routines to
help out.
Nov 13 '05 #10
Salad wrote:
And of course http://www.mvps.org/Access has a good stock of routines to
help out.


make that http://www.mvps.org/access
Nov 13 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have...
5
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have...
5
by: ziggs | last post by:
I have an Access 97 DB called employees.mdb within a NT security type folder. Other users have write privileges to this document to make updates. This Access DB is only used for an ASP called...
1
by: Marcin Floryan | last post by:
Hello! My question regards opening (and re-opening) Form and the Load event. I have a main form (frmMain) and I also have a data form (frmData). In the main form I have created: Private...
7
by: Jean-David Beyer | last post by:
I have six hard drives (4 SCSI and 2 EIDE) on my main machine with parts of a database on each drive. The main index is on one SCSI drive all to itself. The main data are on the other three SCSI...
3
by: RicercatoreSbadato | last post by:
I use Win XP, which is the maximum number of sockets I can open on the localhost?
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
1
by: Juliano.net | last post by:
I have an ASP.Net web site built on C# that uses Oracle database, in some pages, I get an error "max number of cursors opened exceeded". I've a tipo on www.CodeProject.com that asks to call...
4
by: vanderschoork | last post by:
Hi, I'd like to record how many times an Access database I've created is opened. Ideally I'd like to record the date\time the user opens it and their user name into a separate table in the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.