• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 792
  • Last Modified:

Cannot assign value to text box.

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
Neil2526
Asked:
Neil2526
  • 3
  • 2
1 Solution
 
Shanmuga SundaramDirector of Software EngineeringCommented:
why not try in other event. for eg in load event?
0
 
gemailjCommented:
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
 
Neil2526Author Commented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
gemailjCommented:
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
 
Neil2526Author Commented:
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
 
Neil2526Author Commented:
figured it out, i didn't use .Text, but i ended up placing the assignments in the Details Format section
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now