various ways to do it. But in principle, when your user logs in, store the login ID in a global variable in a module. then in your forms in the form before update event, assign the global variable value to the userid field.
Sorry. Would you please explain in a sample?
Another approach is to store the login ID in a textbox on a form that never closes, such as a MainMenu. Then code references the textbox to get the ID. I use this approach because global variables lose their value when runtime errors occur. Control's DefaultValue property can even reference the textbox on MainMenu to autopopulate.
And even another approach is to use a TempVar to hold the ID. They don't lose value. I have never used TempVar.
A global variable is declared in a general module header then code in another module (the login form) sets the variable value. More code in your data entry form module references the variable to populate field. Bing: Access global variable. Here is one http://www.blueclaw-db.com/access_da...l_variable.htm
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I used the TempVar to store current User ID in a text box. Thank you. Now I need to refer a table field to read this value from my form textbox. The form that contains textbox is "frmLogin", the textbox is "text17", the table Which I need to store the textbox value is "tbl_rec_reg" and the field name is "logger".Another approach is to store the login ID in a textbox on a form that never closes, such as a MainMenu. Then code references the textbox to get the ID. I use this approach because global variables lose their value when runtime errors occur. Control's DefaultValue property can even reference the textbox on MainMenu to autopopulate.
And even another approach is to use a TempVar to hold the ID. They don't lose value. I have never used TempVar.
A global variable is declared in a general module header then code in another module (the login form) sets the variable value. More code in your data entry form module references the variable to populate field. Bing: Access global variable. Here is one http://www.blueclaw-db.com/access_da...l_variable.htm
As Ajax indicated, use code in form BeforeUpdate event to populate field of new record (or alternatively, use DefaultValue property and no code needed).
However, your image shows a table with existing records. If you want to populate all those records with the same value, then run an UPDATE query.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Thank you very much. "TempVar" worked fine as below. But when I tried to fill the current date and time along with logger, it doesn't work and says there's a syntax error:As Ajax indicated, use code in form BeforeUpdate event to populate field of new record (or alternatively, use DefaultValue property and no code needed).
However, your image shows a table with existing records. If you want to populate all those records with the same value, then run an UPDATE query.
Also, Each time I log in db, this message appears:
And a new record is created in the log table as below. But I want to replace the new logger ID with the previous one and have just one record
![]()
Date is a reserved word. Should not used reserved words as names for anything. If you do, enclose in [ ]: [date].
Don't understand issue. INSERT sql inserts a new record. If you want to edit existing record then use UPDATE sql.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Did anyone else notice that we're dealing with either a lookup or multi-value field here?
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.