Solved

Cannot assign value to text box.

Posted on 2008-10-02
6
784 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
Industry Leaders: 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!

 
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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
MS Acccess - Update Field in Table when report is printed 6 51
VBA Shell can't Find Word document 11 130
Visual Studio 2005 text editor 10 48
Added a column screws up code 5 69
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

756 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