Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / August 2005

Tip: Looking for answers? Try searching our database.

Runtime error "you can't assign a value to this object"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Amit - 04 Aug 2005 00:40 GMT
MS Access 2K, Windows XP
=====================
Hi,

I have a simple form with the following code in the forms's On Load event:
=====
  Me.RecordCreatePerson = fOSUserName()
  MsgBox "Current user is " & CurrentUser()
   Me.CurrentUserName = CurrentUser()
=====
I also have  hidden text controls on the form bound to the corresponding
fields (of type text) for capturing Windows/Network username and the Access
username in the table.

When I open the form, there are instances when it works fine (the value from
fOSUserName and CurrentUser are nicely stored in the table), and at some
other instances, it gives me the error at the first line:
"You can't assign a value to this object."

The only other code I have is in the form's On Open event -
"Docmd.Maximize", and of course, the module.

Is there any reason why this would work some time, and not other times? The
message says "run time error '-2147352567 (80020009)': You can't assign a
value to this object."

Should this code be placed in the OnCurrent event of the form instead? I
think On Open is too early to assign values.

Thanks.

-amit
Nikos Yannacopoulos - 04 Aug 2005 08:31 GMT
Amit,

I suspect you're right, the On Load is probably too early. Try the
Current event. While you're at it, you could make it dependent on
Me.NewRecord = True, so it doesn't execute as you browse through
existing records (I realize this is probably a data entry form, just
giving you  - and other readers possibly - the general idea).

HTH,
Nikos
Amit - 04 Aug 2005 16:56 GMT
Hi Nikos,

Thanks for the response. Yes, I moved the code to OnCurrent (with If
me.newrecord..) and it is working now.  

I think the issue could have been when I moved from one record to the other.
In that case, OnLoad would not trigger, because the form is already loaded. I
could be wrong about this.

Thanks.

-Amit
Nikos Yannacopoulos - 05 Aug 2005 07:28 GMT
No, you're not wrong, this is indeed the case. If you wanted this to
work on every record, then the Current event is the right one. The Load
event fires only once, right after the form is opened.

Nikos
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.