Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass a text from a forms text box to a datareport label 1

Status
Not open for further replies.

giyer555

Programmer
Sep 8, 2003
75
IN
Hi!!! Experts

In VB 6 datareport how do I pass a text from a forms text box to a label in datareport

Please help
 
Did you do a search on the forum - I'm sure I answered this recently - Ah, yes, here it is: thread222-613349

Check out faq222-2244 to get better answers!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Thanx!!! big brother I really appreciate ur timely help

Forgive me for posting the thread twice

 
Thanx!!! big brother I really appreciate ur timely help.

I checked out your reply & will get back to you after working it out.
Forgive me for posting the thread twice.

 
Johnwm I tried passing the text from a text box on a form
to the report label but it didn't work out

I have placed the label in the report header (Section 4) & tried to pass the text from a forms text box using

dr1.Sections(4).Controls("label1").Caption = "HELLO"

Kindly guide
 
1. Are you using the MS Datareport control, with name set to 'dr1'?
2. Are you running VB6 with SP5?
3. Is your label control called 'Label1' with Visible property set to True?

If all these check out, what error are you getting? If you set the label's caption at design time, does it show OK?

I guess these are the obvious ones to check, but I use that code often, and I know it works

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Johnwm
sorry for posting the thread twice but as i thought i have posted it in the wrong forum i reposted it in the correct one.

I am using MS Datareport control & the name is also correct.
Regarding ur 2nd Q Are you running VB6 with SP5?
Yes, I am using Ms Windows Common Control 6.0 (SP4)

The label name is correct & the visible property is set to true.

Kindly advice SP4

Thanx


 
While in IDE check Help|About. The top line should read Microsoft Visual Basic 6.0(SP5)

AFAIK the DataReport designer dll was updated in SP5, which is downloadable at:

After doing the upgrade (if necessary), can you also answer my previous <If all these check out, what error are you getting? If you set the label's caption at design time, does it show OK?>

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Hi!!! Johnwm

I have downloaded the VB SP 5 & installed the same.
Now i am receiving a subscript out of range error

I have set the label's caption at design time

Kindly guide

Thanx
 

1. If you do not set the caption value in the report's Initialize event, then you will need to call the Refresh method after setting the caption value.

2. If the label is in the details section, and there is not data to show there, then the lable will not show either, I guess.

 
Thanx CCINT

Actually I need to pass text from a forms text box & combo box to labels in datareport using command button.


Private Sub cmdretrieve_Click()
On Error Resume Next
DataEnvironment1.rsvaredit.Close
If optbranch.Value = True Then
ssql = &quot;select emp_earnded.*, emp_name from emp_earnded, emp_mast where emp_earnded.emp_code = emp_mast.emp_code and month = &quot; & cbomonth.Text & &quot; and year = &quot; & cboyear.Text & &quot; order by emp_earnded.br_code, emp_earnded.emp_code&quot;
DataEnvironment1.Commands(4).CommandText = ssql
'testing
dtrvaredit.Sections(4).Controls(&quot;Label28&quot;).Caption = &quot;hello&quot;
dtrvaredit.Show
ElseIf optempcode.Value = True Then
ssql = &quot;select emp_earnded.*, emp_name from emp_earnded, emp_mast where emp_earnded.emp_code = emp_mast.emp_code and month = &quot; & cbomonth.Text & &quot; and year = &quot; & cboyear.Text & &quot; order by emp_earnded.emp_code, emp_earnded.br_code&quot;
DataEnvironment1.Commands(4).CommandText = ssql
dtrvaredit.Show
End If
 
1. Are you sure that your <On Error Resume Next> is not covering some other problem?

2. Are you sure that <optbranch.Value = True > ?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Johnwm thanx for the reply

What I have mentioned is just to show how i want to pass the text from the text box & combo box to the datareport label.

and the optbranch.value is true

Only try changing the label caption to &quot;hello&quot; that too does not work. Once it works i will pass on the text box value to the label.

Thanx
 
And the answer to my first question? Are you sure that your <On Error Resume Next> is not covering some other problem?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Johnwm
<On Error Resume Next> Is used just in case the
<DataEnvironment1.rsvaredit.Close>
is closed

It refreshes the datareport everytime the user clicks on the retrieve button.

U can just try the code mentioned below using a cmd button. It does not work
dtrvaredit.Sections(4).Controls(&quot;Label28&quot;).Caption = &quot;hello&quot;

 
Hi giyer55,

If I want to check if dataenvironment1.rsvaredit is closed, I check the State with an If..Then block rather than using On Error Resume Next so, as Johnwm indicates, not to hide some other problem (been there, done that making it tough to find the real problem).

Jim

 
I suppose you've checked that your label is in Sections(4)
The mapping between setion numbers and names appears to be arbitrary. To be sure, use the Name of the section rather than its number.


dr1.Sections(&quot;mysectionname&quot;).Controls(&quot;label1&quot;).Caption = &quot;HELLO&quot;

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top