Forum Discussion
2 of the 3 works
Hello all, I have these 3 lines of code, and the first 2 works, but I cannot make the 3 third ones work. I need the user name on the login form to be pasted on the frmlogbookEntry. Can anyone give a suggestion, Please?
Forms![frmLogbookEntry].[LogData] = [UserName] & " On site,and Logged In ."
Forms![frmLogbookEntry].[LogType] = "logIn"
Forms![frmLogbookEntry].[OfficerName] = Forms![frmLogin].[UserName]
Francisco
- George_HepworthSilver Contributor
Where are these lines of code running? How are they triggered?
Is the form called "frmLogin" actually open when this line runs? (It must be open to work.)
Does it have a valid value in it when the line of code runs?Is Forms![frmLogin].[UserName] a bound control?
- Francisco_CuartasCopper ContributorHello George, this is the code that opens the logbook entry
stDocName = "frmLogbookEntry"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Forms![frmLogbookEntry].[LogData] = [UserName] & " On site,and Logged In ." ==the UserName does not work, the other part does
Forms![frmLogbookEntry].[LogType] = "logIn" ==This line works
'Forms![frmLogbookEntry].[OfficerName] = Me.[UserName]== Does not work
DoCmd.Save
DoCmd.Close- George_HepworthSilver Contributor
Please post the COMPLETE procedure, starting with the declaration as Private or Public and ending with the close, End Sub or End Function, not snippets from it.
Also, please confirm that this code runs on some event in the form named frmLogin. Which event? A command button click?
Again, it's also useful to have answers to my specific questions, including the actual value in the control called UserName on the form called [frmLogin]. Is UserName a bound control? What kind of control is it? Thank you.PS: Maybe in this case actual screenshots of the two forms would also be helpful. Thanks again.