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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 printing report problem

Status
Not open for further replies.

Brendan

Programmer
Aug 9, 1999
5
0
0
AU
Visit site
giday all,<br>
<br>
Hope someone may have they answer to this one. I have a form where the user enters a customer number then hits a print button. behind the print button it changes commandText property's sql statement to retrieve that customer's personal details - all is fine the first time entered.<br>
<br>
here is the SQL line of code:<br>
DataEnvironment1.Commands(&quot;cmdSinglePilot&quot;).CommandText = &quot;SELECT TCustomer.*, &quot; & &quot;custNo AS No FROM TCustomer WHERE (custNo = &quot; & txtInfo & &quot;) <br>
<br>
txtInfo is the number entered by the user!<br>
<br>
However, unless the program is stopped then re-run, when enetering a new customer number, even though the sql statement is updated (have definately checked), the old customers details always show up. <br>
<br>
I have tried using the update function for both the dataEnvironment object and the command object which has the SQL statement attached to it, but no luck.<br>
<br>
It is as if the SQL statement has been changed but never executed therefore the same report details contine to be shown no matter what customer number is entered!<br>
<br>
Look forward to hear from someone who has either had the same problem or found a solution.<br>
<br>
Thanks<br>
<br>
<br>
Brendan (Australia)
 
This may sound to simple but I wasn't sure by you description of the problem so here goes. Did you clear your old variable or text box or whatever before doing the new SQL String? Or are you using a Data bound control?
 
Giday Spacey,<br>
<br>
The SQL that is built on the fly, gets it's customer number from an everyday textbox. The first time I enter a number into the text box it works fine for whatever number and the report displays fine. The problem occurs when I close the report and enter a new number into the text box (the old screen is in the background) - the old customer's numbers details are displayed again. <br>
<br>
I know the SQL string is changing, as after I have changed it I print out the change to the SQL string in the Immediate window.<br>
<br>
You see the SQL is initially hardcoded to print customer '1' at design time. Then at run time the SQL does work properly the first time I enter a correct number into the text box but not any following times - so bloody frustraiting.<br>
<br>
Even if I close the old report screen where the text box is located it doesn't matter. The only way to enquire on another number has been to restart the application.<br>
<br>
It must be something simple as I know the SQL string property in the Data Enviroment's command has definately changed but all attempts to refresh or update the command have not worked!!!!!<br>
<br>
Here is the Heirarchy of the DataEnvironment in case it makes it clearer:<br>
<br>
DataEnvironment1 (DE1)<br>
¦_DynamicFlight (name of connection to DE1)<br>
¦_cmdAllCustomers (name of command added)<br>
¦_cmdSingleCustomer (as above - this is where the<br>
customer number is changed to it's<br>
SQL string property)<br>
<br>
I hope this clarifies things a little more. Any further suggestions would be appreciated!<br>
<br>
Thanks<br>
<br>
Brendan.
 
Whenever I have used the DataEnvironment I tend to use recordsets and filters to perform what you are trying to do.<br>
<br>
Typically I might try along the lines of the following code:<br>
<br>
With DataEnvironment1.rscmdSinglePilot <br>
.Filter="custNo=" & txtInfo.Text<br>
.Requery<br>
End With<br>
<br>
Doing it this way you would first set your initial command to SELECT all records in TCustomer.<br>
<br>
I hope this may be of some use to you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top