Avatar of 4charity
4charity
 asked on

Form - Cannot Assign Value

This is weird. I have another db set up to do a similar thing, but cannot replicate it here.
I have a form that has a bunch of buttons on it to run reports. I want to capture when the form was opened, and who opened it. I put two non-visible controls on the form "OpenDate" and "User". I created a table with these two fields. The idea is to log the current date/time, and the userID in those fields when the form is opened. On the Form_Open event, I have:

Me.OpenDate = Now()
Me.User = GetUserCredentials(2)

I get a 'You can't assign a value to this object' error for the first line, and 'Sub or Function not defined' for the second line.

Microsoft Access

Avatar of undefined
Last Comment
4charity

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
NEVAEHSIN

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
cgrogan

I think because you are using form_open instead of form_load, and the controls are bound you are getting the error.  Try moving your code to the form_load instead.
4charity

ASKER
I added the module for the function "GetuserCredentials(2)", and I removed the hidden controls on the form.

Perfect.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck