×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

VB6 printing report problem

VB6 printing report problem

VB6 printing report problem

(OP)
giday all,

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.

here is the SQL line of code:
DataEnvironment1.Commands("cmdSinglePilot").CommandText = "SELECT TCustomer.*, " & "custNo AS No FROM TCustomer WHERE (custNo = " & txtInfo & ")

txtInfo is the number entered by the user!

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.

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.

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!

Look forward to hear from someone who has either had the same problem or found a solution.

Thanks


Brendan (Australia)

RE: VB6 printing report problem

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?

RE: VB6 printing report problem

(OP)
Giday Spacey,

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.

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.

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.

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.

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!!!!!

Here is the Heirarchy of the DataEnvironment in case it makes it clearer:

DataEnvironment1 (DE1)
¦_DynamicFlight (name of connection to DE1)
¦_cmdAllCustomers (name of command added)
¦_cmdSingleCustomer (as above - this is where the
customer number is changed to it's
SQL string property)

I hope this clarifies things a little more. Any further suggestions would be appreciated!

Thanks

Brendan.

RE: VB6 printing report problem

Whenever I have used the DataEnvironment I tend to use recordsets and filters to perform what you are trying to do.

Typically I might try along the lines of the following code:

With DataEnvironment1.rscmdSinglePilot
.Filter="custNo=" & txtInfo.Text
.Requery
End With

Doing it this way you would first set your initial command to SELECT all records in TCustomer.

I hope this may be of some use to you.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close