use formfield value in a query

Alg1961

New member
Local time
Today, 17:48
Joined
Nov 1, 2004
Messages
8
I want to record the form name and the username when a users opens a form.

The username works with the getuser() function but the form name or any other identifying form item does not.

On each form I also have put a hidden field called ID but even the value of this does not return to my query that starts on the on open function.
:confused:
 
So you have a form, based on a table/query. And for one of the flds, you want to store the forms name as the deault value so you'll know what form was used to add records?

???
kh
 
logging

I want to log the formname or the contents of a identifying field on the form to be able to see which user has used a form.
 
Are you wanting to store this info in a seperate, stand alone log type table?

kh
 
userlogging

No just i a table in the same database.
 
Hum... The last two threads looks the same to me (?!?)

Anyway, I would just do a simple append query for each form and then execute them on the form open events. The append queries would append a new record each time a form opens, inserting the user name, etc.

Would this work?
kh
 
I'm pretty sure me.name returns the name of the current form.
 
field mnu: [me].[name]

append to menu

Sorry tried that. Then I get the question "enter parameter value" [me].[name]
 
Alg, Would something like this work - See attachment.

kh
 

Attachments

Thanks Ken. But what I am looking for is one query for more than one form.

So in the query where "appLogForm1" is appended to the logvalue there should be the formname.

// Alg
 
The query has no idea what 'me' is. (Bad grammer ?!?).

If you're going about it this way, do a puplic var, put the form name there and then use it in the query.

???
kh
 
Or, I would just place something like the following in the open event for each form:


Code:
Dim strSQLStatement As String
Dim strFormName As String

strFormName = "What ever the forms name is goes here"

strSQLStatement = "INSERT INTO tblLog ( logValue ) SELECT '" & strFormName & "' AS Expr1;"

DoCmd.SetWarnings False

DoCmd.RunSQL strSQLStatement

DoCmd.SetWarnings True


kh
 
I decided to run the code "on open". Great logging. Exept after one hour the tbllog file was over 4.000.000 records. Had to remove it. My access database is used by about 35 people 24 hours a day. So I have to learn a bit more about how access behaves in a network.
But it's like my colleage allways says: "there's humour in everything" :o)
 
4.000.000 - You're kidding, right?

kh
 
No, 4.000.000 and more. The database is located on a server. And it looks like access opens the same menu several time a minute and does this for every user.
 

Users who are viewing this thread

Back
Top Bottom