Solved

Form - Cannot Assign Value

Posted on 2010-09-08
4
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

738 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