?
Solved

Cannot assign value to text box.

Posted on 2008-10-02
6
Medium Priority
?
788 Views
Last Modified: 2012-05-05
Seems like an easy one...

I have a global variable that I am correctly populating. I want to take that var and put it in a report to print. Below is my code for the report. I get a

Run-time error '-2147352567(80020009)':
You can't assign a value to this object.

My globals are defined as:

Global globalUsername As String

Thanks.
Private Sub Report_Open(Cancel As Integer)
Me.Text32 = globalFirstName
Me.Text34 = globalLastName
Me.Text35 = globalUsername
Me.Text36 = globalPW
End Sub

Open in new window

0
Comment
Question by:Neil2526
[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
  • 3
  • 2
6 Comments
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 22625500
why not try in other event. for eg in load event?
0
 
LVL 5

Expert Comment

by:gemailj
ID: 22625547
all you have to do is to use Text property instead of assign a string to the textbox
like this  (Me.Text32.Text = globalFirstName)
instead of (Me.Text32 = globalFirstName)
Private Sub Report_Open(Cancel As Integer)
Me.Text32.Text = globalFirstName
Me.Text34.Text = globalLastName
Me.Text35.Text = globalUsername
Me.Text36.Text = globalPW
End Sub

Open in new window

0
 

Author Comment

by:Neil2526
ID: 22625579
Almost there, gemailj.

I used your suggestion and got an error about focus. So I then added:

Me.Text32.SetFocus before assigning values.

I then got the following error:

myDatabase does not allow you to use this method in the current view.

Does that have anything to do with the way I am calling the report?
below...
DoCmd.OpenReport "rptUsername_Password_populated", acViewPreview

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Expert Comment

by:gemailj
ID: 22625950
no it is not related with how you openthis report,
it is about using this code in -- open event
try to use it in -- load event
0
 

Author Comment

by:Neil2526
ID: 22626560
Thanks for the info, i am currently using this and my break point is  not getting hit.
Private Sub Report_Load()
Me.Text32.SetFocus
 
Me.Text32.Text = globalFirstName
Me.Text34.Text = globalLastName
Me.Text35.Text = globalUsername
Me.Text36.Text = globalPW
End Sub

Open in new window

0
 

Accepted Solution

by:
Neil2526 earned 0 total points
ID: 22627588
figured it out, i didn't use .Text, but i ended up placing the assignments in the Details Format section
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

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