×
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

Working With Two Tables

Working With Two Tables

Working With Two Tables

(OP)
Ok what I want to do is I want to export data from two tables into one excel sheet but the tables have the same name and what i want is to export the information from the tables where the customer number is the same it must put the number and name from one table and the cash data from the other table with is specified between two dates in one excel sheet here is my code for selecting the data from one table between two dates:

mysql = "Select CustomerCode,Description,Date from HistoryLines where " & Chr$(34) & "Date" & Chr$(34) & " Between '" + txtFrom.Text + "' And '" + txtTo.Text + "'"

I need this to be modified to pull my requested data out of the Pervasive SQL database

RE: Working With Two Tables

Sounds like you need a join condition.  
Without knowing the exact structure of the table, I'm only guessing but it'll probably look like:
select T1.Number, T1.Name, T2.CashData from T1, T2 where T1.Number = T2.Number

You'll need to change the field and table names to match your data.

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
Custom VB and Btrieve development.
http://www.mirtheil.com

RE: Working With Two Tables

(OP)
OK I could do that but then I loose my date query because i need that line of code you gave me to be altered in away so that it pulls that data out between two dates and two tables.

RE: Working With Two Tables

The query I gave is an example.  You would need to modify it to match the restrictions you need.

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
Custom VB and Btrieve development.
http://www.mirtheil.com

RE: Working With Two Tables

(OP)
I modified it like this but it only gives me the data from one table:

mysql = "Select CustomerMaster.Number,CustomerMaster.Description,Date from CustomerMaster,HistoryLines where " & Chr$(34) & "Date" & Chr$(34) & " Between '" + txtFrom(0).Text + "' And '" + txtTo(0).Text + "' And CustomerMaster.Number=HistorlyLines.CustomerCode"

RE: Working With Two Tables

That's because you aren't specifying any fields from the second table.  If "Date" is in both tables, you are going to seend to specify which table you want the data to come from.

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
Custom VB and Btrieve development.
http://www.mirtheil.com

RE: Working With Two Tables

(OP)
OK so my line of code is right and Date is only in the historylines table but there where is specified the CustomerMaster.Number and The CustomerMaster.Description that data comes from the historylines table and not from the customermaster table like i specified

RE: Working With Two Tables

(OP)
OK when I export I gives me Only three Fields which is number,name and the date from the HistoryLines table nothing from the customermaster table

RE: Working With Two Tables

(OP)
Thanx For all your help and i learned alot from you guys I will recomend this site to all my programming friends
You guys ROCK BIG TIME and i specially want to thank mirtheil for all the help and we will talk again of not in this life time then in the after life
Enjoy the rest of the night or day and be good and keep up the good work and keep this forum alife

And by the Way:
I'm from south africa and want to meet you guys one day.

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