Results 1 to 4 of 4

Thread: multiple commands in APPEND

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    7

    multiple commands in APPEND

    hi friends
    i want to use multiple queries an APPEND clause. I used the following code but it gives syntax error. plz help me as soon as possible.


    rs.Open "Shape {SELECT DISTINCT sem From qAwd WHERE seat_no=" & stno & " AND class= '" & deg & "' ORDER BY sem} As Parent Append (({Select crs_title, crs_no, cr_hrs, lab, midterm, terminal, total_marks, total, crs_index, remarks, sem, ayr From qAwd WHERE seat_no=" & stno & " ORDER BY sem, crs_no, exm_date} Relate sem To sem) As com1) Append (({Select total, sem From qAwd WHERE seat_no=" & stno & " AND remarks='" & passStudetn & "' ORDER BY sem} Relate sem To sem) As com2)", con, adOpenStatic, adLockReadOnly, adCmdText

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: multiple commands in APPEND

    Do you want a Parent Child, Child relation or Parent, Child, GrandChild relation?

    I assumed Parent Child, Child.

    For that you only need 1 Append clause, with each Select clause separated by a ,. Also, the alias name of the Chapter must appear before the Relate clause.

    VB Code:
    1. rs.Open "Shape {SELECT DISTINCT sem From qAwd WHERE seat_no=" & stno & " AND class= '" & deg & "' ORDER BY sem} As Parent " _
    2. & "Append ({Select crs_title, crs_no, cr_hrs, lab, midterm, terminal, total_marks, total, crs_index, remarks, sem, ayr From qAwd WHERE seat_no=" & stno & " ORDER BY sem, crs_no, exm_date} As Com1 Relate sem To sem), " _
    3. & "({Select total, sem From qAwd WHERE seat_no=" & stno & " AND remarks='" & passStudetn & "' ORDER BY sem} As Com2 Relate sem To sem) ", con, adOpenStatic, adLockReadOnly, adCmdText

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    7

    Re: multiple commands in APPEND

    thanks a lot , this query solves my prob..but now i have another problem i.e. when i try to display any field e.g. (semTotal) of com2 in a textBox it gives error " Data Field semTotal[Com2] not found", Actually i want to show this field in the DataReport's Group Footer. the code i used is:
    VB Code:
    1. rs.Open "Shape {SELECT DISTINCT sem From qAwd WHERE seat_no=" & stno & " AND class= '" & deg & "' ORDER BY sem} As Parent " _
    2. & "Append ({Select crs_title, crs_no, cr_hrs, lab, midterm, terminal, total_marks, total, crs_index, remarks, sem, ayr From qAwd WHERE seat_no=" & stno & " ORDER BY sem, crs_no, exm_date} As Com1 Relate sem To sem), " _
    3. & "({Select SUM(total) As semTotal, sem From qAwd WHERE seat_no=" & stno & " AND remarks='" & passStudetn & "' GROUP BY sem ORDER BY sem} As Com2 Relate sem To sem) ", con, adOpenStatic, adLockReadOnly, adCmdText
    4. Set dResult.DataSource = rs
    5. dResult.Show
    6.  
    7. With dResult.Sections("Section7")
    8. .Controls("txtSemTotal").DataField = semTotal
    9. .Controls("txtSemTotal").DataMember = Com2
    10.  
    11. End With

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    7

    Re: multiple commands in APPEND

    I think the reason of this error is that sometimes no record exist for Com2 while there is a number of records for Com1. Actually Com1 returns the marks obtained by a student in different subjects of each semester Whether the student passed that course or failed. in the other hand, Com 2 returns the marks of only that courses that are passed by the student as i wanna calculate the sum of passed courses and display it in the group footer, but i also want to show the marks of all courses of a semester in the group detail section. For some semesters the student is fail in all the courses i.e. no record exist for Com2. Now plz tell me how can i deal with this prob. how can i write a code to show the semTotal field if there are records for Com2 and not to show it if no record exist for Com2. plz help me

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