473,385 Members | 1,769 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,385 software developers and data experts.

Writting data into a table with VB (I think)

I wish to add usage records to a table to show how many times each of the
buttons on my main menu are used.

I am envisaging a table which contains the following data:

User: Button: Time:
Fred Suppliers 10/10/04 03:54:45

The user will be the name of the individual who clicks on the button.
The button will store the name of the button pressed and the time field will
store the time when it was pressed.

There are approximately 50 buttons on the main menu with even more on
subforms and user specific menus.

The best way to do this that I can see is to add code to the OnClick event
in the following manner:

Private Sub Button1_Click()
RecordNavigation(1)
End Sub
Private Sub Button2_Click()
RecordNavigation(2)
End Sub

Function RecordNavigation(ButtonNo)
//////////////////////////////////////////////////////////////////////////
??How do I then write the three fields into the database
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\
End Function

Any help would be greatly appreciated.

John.

P.S. I appologise if this is not the ideal NG but I am happy to repost it
elsewhere if somebody can rcommend a more appropriate one.

Nov 13 '05 #1
3 1136
Place the following code into a standard module.
************************************************** ******
Public Sub RecordNavigation(strButton As String)
On Error Goto RecordNavigation_Err
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDB
Set rst = db.OpenRecordset("YourTableName")
With rst
.AddNew
!User = HowYouGetTheUser'sName
!Button = strButton
!Time = Now()
.Update
End With
RecordNavigation_Exit:
On Error Resume Next
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Sub
RecordNavigation_Err:
MsgBox Err.Description, vbInformation, "Record Navigation"
Resume RecordNavigation_Exit
End Sub
How to use.
**************
Private Sub Button1_Click()
YourOtherCodeBehindTheButton
RecordNavigation("YourButtonName")
End Sub

Private Sub Button2_Click()
YourOtherCodeBehindTheButton
RecordNavigation("YourButtonName")
End Sub

I'd advise to change the name of the "Time" field to something else to say
TimeActivated or TimeUsed or something similar. Time is a reserved name in
Access and can lead to conflicts between the field name and the built in
Time() function.

Jeff
"John Ortt" <Jo******@Idontwantspamsonoreturnaddress.com> wrote in message
news:41**********@baen1673807.greenlnk.net...
I wish to add usage records to a table to show how many times each of the
buttons on my main menu are used.

I am envisaging a table which contains the following data:

User: Button: Time:
Fred Suppliers 10/10/04 03:54:45

The user will be the name of the individual who clicks on the button.
The button will store the name of the button pressed and the time field will store the time when it was pressed.

There are approximately 50 buttons on the main menu with even more on
subforms and user specific menus.

The best way to do this that I can see is to add code to the OnClick event
in the following manner:

Private Sub Button1_Click()
RecordNavigation(1)
End Sub
Private Sub Button2_Click()
RecordNavigation(2)
End Sub

Function RecordNavigation(ButtonNo)
//////////////////////////////////////////////////////////////////////////
??How do I then write the three fields into the database
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\
End Function

Any help would be greatly appreciated.

John.

P.S. I appologise if this is not the ideal NG but I am happy to repost it
elsewhere if somebody can rcommend a more appropriate one.


Nov 13 '05 #2
That looks excellent Jeff.

Thankyou for your time and I'll let you know how I get on.

John

"Jeff Smith" <No***@Not.This.Address> wrote in message
news:ci**********@lust.ihug.co.nz...

<Snipped>
Nov 13 '05 #3

"John Ortt" <Jo******@Idontwantspamsonoreturnaddress.com> wrote in message
news:41**********@baen1673807.greenlnk.net...
That looks excellent Jeff.

Thankyou for your time and I'll let you know how I get on.

John


Worked a treat. Thanks Jeff.

Now to fill the code in for all the rest of the buttons :)
Nov 13 '05 #4

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

Similar topics

8
by: Woody Splawn | last post by:
Lets say I have a winform that is populated with a dataset. The dataset and data table may have several rows in it. Lets say I am looking at the winform and I want to assign a value to a certain...
2
by: Brian Mitchell | last post by:
Ok, I know this is an elementary question but I have a data grid that is bound to a data table and I can't seem to find a way to match the selected row in the grid with it's respective row in the...
11
by: Ron L | last post by:
I have a data table that lists a series of items in my database. In my user form, I want the user to be able to filter by a number of criteria (e.g. location, contract, date modified, etc). Other...
1
by: John | last post by:
Hi When using Table Adapter Configuration Wizard if 'Use SQL Statements' is selected as Command Type, the data table's name in dataset is retained and only its data adapter's select statements...
1
by: Kwok | last post by:
In my project... which deadline is July 3 .... I need to design a very simple database.... which can enter some subject or subheading in a document to a data table in MS access. I use VB to...
1
by: DH | last post by:
I have an untyped dataset with a table. I am trying to programmatically add a row to this table. This was working in VS 2003 / .net 1.1 I am receiving an error "Object reference not set to an...
1
by: laredotornado | last post by:
Hi, I have a data table on my page (buried amidst other images and extraneous text). I would like to spawn a new window that automatically prints the content of my data table, and only that...
3
by: Ctal | last post by:
I have an app that populates several data tables on load. Each of these are bound to a datagrid. Above each datagrid I have several text boxes that display the data for the active row. There are...
7
by: sathyashrayan | last post by:
Dear group, A mysql wrapper class, which just uses the CRUD operations for large scale php development. Is the same advisable for the mysql stored procedure? Following is a link I got from...
1
by: BaseballGraphs | last post by:
Hello, I am trying to divide one value from my data table with an associated ID by another value from my data table with a different ID for the same day that the value was added to the data table....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.