Temp variable to get added to table/form

kevinoc

New member
Local time
Today, 13:09
Joined
Oct 23, 2015
Messages
3
Hi,

I have set up a login form to assign a temporary variable to the current session, which will be the username. I am now having difficulty getting this value to propagate elsewhere. I need this value to go to the various tables and consequently forms elsewhere.

For context, main login form sets the temporary variable, TempVars!TempLoginID; I want this TempVars!TempLoginID to go to other tables and forms for that session, so to allow tracking of what user entered what.

Please advise as a matter of urgency.

Thank you and appreciated
 
If you do
Code:
TempsVars!TempLoginID = "John"
This should be accessible on all the other forms.
In all the forms you can do
Code:
textbox.value = TempVars!TempLoginID
 
Hi Grumm

Thank you. I have done this - it is visible, but I cannot get this to go to the table feeding the form. I need my 'user' field to capture the login at the time the record is saved. Do you have any ideas?
 
There should be a event called BeforeUpdate.
You can use that to put the correct username in the field 'user' then save the record.
(I use sometimes AfterUpdate too. It all depends what you want to do)

But maybe other people here can get a better solution with just correct relations between the 2 tables.
 
Thank you, Grumm. If possible, does anybody know how to provide a quick solution to the above? I.e. a temporary variable propagating in forms and tables during a session?

Thanks
 
Save it in a table. It's a database. Make a table like . . .
tSessionVariables
VarID (PK)
Name (Unique Index)
Value
Now you can save and retrieve name/value pairs at will. You can also expose a function or property that always returns the value at a certain name, like . . .
Code:
Function GetSessionUsername as string
   const SQL as string = _
      "SELECT Value FROM tSessionVariables " & _
      "WHERE Name = 'Username'"

   with currentdb.openrecordset(sql)
      GetSessionUsername = .Fields(0).Value
      .close
   end with
End Function
. . . and you can write a sub that saves data just like that. You can also write a function to which you pass the Name, and it returns the Value.
 

Users who are viewing this thread

Back
Top Bottom