Oct 25 2021 04:52 PM
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
Oct 25 2021 05:02 PM
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?
Oct 26 2021 04:46 PM
Oct 26 2021 05:03 PM - edited Oct 26 2021 06:01 PM
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.
Oct 26 2021 11:42 PM
Oct 27 2021 06:41 AM
Oct 27 2021 02:31 PM
Oct 27 2021 03:32 PM
This line closes the form:
DoCmd.Close acForm, "frmLogin", acSaveNo
Why try to do that at that point, given that you are still running additional code, including an attempt to read a value from a control on that same form?
One of the most effective trouble-shooting methods is to put a break point in the code on the first executable line. Then step through the procedure, one line at a time, checking the logic and values to be sure they are what you think they are.
At this point, the only way I could do more analysis would be to have a copy of the actual accdb (with sample data, not real data). Can you provide that?
Oct 28 2021 07:27 AM