Results 1 to 11 of 11

Thread: [RESOLVED] Help with recordset result!

Threaded View

  1. #5
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: Help with recordset result!

    Quote Originally Posted by doctrin13th View Post
    I have 3 table

    1. cat_Tbl = category table which consist of fields:
    catNo = category number (primary key)
    catDesc = category description

    2. prod_Tbl = product table which consist of fields:
    pIndex = index number of a product (primary key)
    pText = product description

    3 FM_Tbl = items ordered(in an order slip) table which consist of fields:
    OSno = Order slip number
    FMitemNo = item number
    Pindex = index number of an ordered product
    FMqty = quantity ordered
    My apologies. I should have mentioned this earlier itself. The three tables you have mentioned should be related to each other. While the FM_Tbl and prod_Tbl are linked through the Pindex, there is no link between the prod_Tbl and the cat_Tbl (at least I don't see one in your post above). Ideally the prod_Tbl should have another column catNo which is a foreign key to the catNo (PK) column of your cat_Tbl table.

    Quote Originally Posted by doctrin13th View Post
    Now, I have an order slip record #12704. in that slip, i ordered several items, each has its unique item number. but when I run the code below, the result set exceeds the number of items i actually ordered. when I check the result, few items were duplicated. this is my code:

    Code:
    strSQL = "SELECT cat_Tbl.catDesc,FM_Tbl.FMitemNo,FM_Tbl.Pindex,FM_Tbl.FMqty,prod_Tbl.Ptext,prod_Tbl.Pum,prod_Tbl.Pprice 
    FROM cat_Tbl,FM_Tbl,prod_Tbl WHERE 
    (FM_Tbl.OSno = " & lngNum & ") AND FM_Tbl.Pindex=prod_Tbl.Pindex AND cat_Tbl.catNo=prod_Tbl.Pcat ORDER BY FM_Tbl.FMitemNo"
        
        ...
    Is there a problem with the strSQL? What's wrong with my code?

    What I want is to display just what I ordered; exact number of items, exact items. and just referencing to other tables its category and product description.
    The query would then look something like this:
    Code:
    strSQL = "SELECT cat_Tbl.catDesc,FM_Tbl.FMitemNo,FM_Tbl.Pindex,FM_Tbl.FMqty,prod_Tbl.Ptext,prod_Tbl.Pum,prod_Tbl.Pprice 
    FROM FM_Tbl inner join prod_Tbl On FM_Tbl.Pindex = prod_Tbl.pIndex INNER JOIN cat_Tbl on prod_Tbl.catNo = cat_Tbl.catNo 
    WHERE (FM_Tbl.OSno = " & lngNum & ")"
        
        ...
    .
    Last edited by honeybee; Jul 21st, 2012 at 04:35 AM.
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

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