Results 1 to 4 of 4

Thread: SQL Query for Access

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    43
    I need a SQL query for Access. I have a table, Policies, with columns 'Type','Age', and 'Duration' . I have other tables Type1, Type2, Type3, and Type4. The rows for these 4 tables are 'Age' and the columns are 'Duration'. I need to use the info from the Policies table to call the correct 'Type' table, and get the data from the correct cell based upon the 'age' and 'duration'. How would I do this in a VB program?

    Is there a way to do this in Access and have the results in a column in the same table or a query or on a form?

    Thanks
    Tim

    VB6, SP4
    GT Vengeance

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    In the POLICIES table, what are the values that appear in the Type column? Is it numeric like 1, 2, 3, 4 or text like Type1, Type2, etc.? You need to somehow match the value of Type of the current record with the table name for that type.

    e.g. if the value is numeric:
    "SELECT * From Type" & myRS.Fields("TYPE").Value & " Where
    AGE = " & myRS.Fields("AGE").Value & " And DURATION = " & myRS.Fields("DURATION").Value


    [Edited by DrewDog_21 on 08-03-2000 at 02:45 PM]

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    43
    'Type' is a text field,as is the names of the other tables, but wouldn't that work if I changed myRS.Fields("TYPE").Value to myRS.Fields("TYPE").Text, or something as such?
    Tim

    VB6, SP4
    GT Vengeance

  4. #4
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Talking

    Yep, that should work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width