Solved

Form - Cannot Assign Value

Posted on 2010-09-08
4
232 Views
Last Modified: 2013-11-28
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.

0
Comment
Question by:4charity
4 Comments
 
LVL 1

Accepted Solution

by:
NEVAEHSIN earned 250 total points
ID: 33629693
Do you have a module in the first data base with the code for the function "GetUserCredentials(2)"?
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) earned 250 total points
ID: 33629698
Forget the hidden controls on the form ... no need.  Instead, do this:

Private Sub Form_Load()
Me![OpenDate] = Now()
Me![User} = GetUserCredentials(2)
End Sub

This writes directly to your fields in the table.

mx
0
 

Expert Comment

by:cgrogan
ID: 33629729
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.
0
 

Author Closing Comment

by:4charity
ID: 33629767
I added the module for the function "GetuserCredentials(2)", and I removed the hidden controls on the form.

Perfect.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question