473,326 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to change the text box value at runtime for a Report

In the Report i need to change the value for a textbox at runtime.Below is my code used to change the value.But i m getting an error "Can't assign value to this object".


Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer)
  2. Dim a As String
  3. a = InputBox("enter the add")
  4. Me.Text2 = a
  5. End Sub
Plz guide me as how can i change the Textbox value at runtime..
Feb 11 '10 #1
6 18364
beacon
579 512MB
You need to change the event to Detail_Format in order for it to assign to the textbox. So, change your code from:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer) 
  2. Dim a As String 
  3. a = InputBox("enter the add") 
  4. Me.Text2 = a 
  5. End Sub 
  6.  
to the following:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2. Dim a As String 
  3. a = InputBox("enter the add") 
  4. Me.Text2 = a 
  5. End Sub 
  6.  
and it should work.

Out of curiousity, what are you using this for? Is your report unbound?
Feb 12 '10 #2
Hello Beacon,
I tried the above code in the Detail_Format event but its not working..
May b I m going something wrong in the Control source property...
Actually the Report in my DB is something like a Label which would randomly go on printing the Address...,once the specific Address is given.So i tried this out with the Input Box..

Below is the Control source property value for the Textbox which shud print the

data as

For ex-South Avenue-3 08 FL 45 1st storey

=[a] & [Plot] & " FL" & [Level] & " - " & [Location].

Plz help me to rectify this..
Feb 22 '10 #3
Your 'a' is something the user is going to type in, so I hope it's something really short ... not a whole address! I'm not sure I know what you are trying to do, exactly. You could have another go at explaining the exact purpose of the report.

Anyway, what you can do is go to report properties 'other' and set the Filter property to ...

Address = Enter_Address

... and the Filter On Load property to Yes

Now when you open the report an 'automatic' input box will come up asking for the address, and the report will open just for that address.

But why do you want to do this?
Feb 22 '10 #4
beacon
579 512MB
Hi Shalskedar,

The solution I sent you works, but only if the text box is unbound. The reason it won't work for you is because your text box isn't unbound. Once you enter something into the Control Source, the text box can no longer have a value assigned to it dynamically, like in my example.

For whatever it is that you are trying to do, since you still haven't really explained what your ultimate goal is, you will have to employ a different method...either using a form to pass your parameter to the query that the report is based on (go to http://www.fontstuff.com/access/acctut08.htm for more details) or maybe using the method that Juliet offered.
Feb 22 '10 #5
beacon
579 512MB
I may have replied too soon. I went back in and removed the control source that I entered in my test database that I was using to recreate your problem, then put the info into the code and it worked, sorta. The input box appears for EVERY record that will appear on your report, so if you typed "123" in the input box, you'll have to type "123" times the total number of records in your report. Not very handy....but here's the code nontheless.

Change this...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) 
  2. Dim a As String  
  3. a = InputBox("enter the add")  
  4. Me.Text2 = a  
  5. End Sub  
  6.  
...to this
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) 
  2. Dim a As String  
  3. a = InputBox("enter the add")  
  4. Me.Text2 = a  & [Plot] & " FL" & [Level] & " - " & [Location].
  5. End Sub  
  6.  
Now, you may be able to input the value into a text box for a group header and then reference the text box using a second text box with a control source, but I haven't had time to test that out or not. Honestly, I think trying that out would be a colossal waste of time and would recommend one of the other solutions Juliet and I suggested.
Feb 22 '10 #6
NeoPa
32,556 Expert Mod 16PB
Put a parameter in the recordsource of the report :
Expand|Select|Wrap|Line Numbers
  1. SELECT [X],
  2.        [Y],
  3.        [Please Enter Address],
  4.        [Z]
  5. FROM   [YourTable]
  6. etc
Feb 23 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: AFN | last post by:
I'm trying to set a submit button to change text and color when clicked. Like saying "please wait" instead of "submit" and then changing the background color and text color. All works, except for...
8
by: Radek Budaø | last post by:
Hi all, i have trouble with changing text value of textbox on runtime. I use this control to display process information about sending e-mail per smtp. I use external component >>Imports...
1
by: Giò | last post by:
Someone knows if is possible to change the value of a property attribute at runtime, via reflection? I'd change the value of DescriptionAttribute, but I don't know if is possible. If isn't, is...
4
by: sid derra | last post by:
hi i am trying to change the value of a text field on my page dynamically, every time an iframe loads. #========== the code where the text field is looks like this: <form...
5
by: Rex | last post by:
Hi, I want to change a value in one table depending on the value(s) in another table. I am trying to achieve this in a form. to elaborate I have a many-to-many relationship between tables...
2
by: Ringo | last post by:
I have a windows app that downloads Firmware to a micro. I display the % done on the form, but I would like to put it in the forms title so that when it is minimized you can see it on the toolbar....
3
by: brent78 | last post by:
I am trying to show whether or not a certain type of transaction has occured. The query result displays the text value of the transaction. Is it possible to have this show up as a true/false check...
3
by: vinodkus | last post by:
dear sir/madam I have a combo which has 2 values I want when its value is changed then its value should be display in a text box. Thanks In Advance
8
by: joshapalooza | last post by:
Hi all, What I'm trying to do is two-fold. We'll tackle one and then the other, or whichever is easiest. First Question/Problem: Is it possible to write VBA code that would change a text...
2
by: deegeorge | last post by:
Hi, I have an aspx form. In that i have a check box for Credit card payment. When i am submitting that form it need to open a crystal report. If the checkbox is checked the textbox field in...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.