Solved

Form - Cannot Assign Value

Posted on 2010-09-08
4
231 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now