-
May 3rd, 2006, 08:36 AM
#1
Thread Starter
Lively Member
linked table help
I have a table with student info with studentID field and I have another table with grades with studentID field linked to student table. How would I get the data with student's name show when I load grades from the table. MidYear is the name table with grades in it. Do I use INNER JOIN and call student ID?
VB Code:
Set rs = New ADODB.Recordset 'as we did with the connection
rs.Open " MidYear ", cn, adOpenKeyset, adLockOptimistic, adCmdTable
-
May 3rd, 2006, 09:09 AM
#2
Hyperactive Member
Re: linked table help
Set rs = New ADODB.Recordset
rs.Open " select student_table.*, midyear.* from student_table inner join midyear on student_table.studentid=midyear.studentid", cn, adOpenstatic, adLockOptimistic, adCmdText
-
May 3rd, 2006, 09:45 AM
#3
Thread Starter
Lively Member
Re: linked table help
thanks that worked. I know the thread should be marked as resolved and I will do that but I have one more question. How would I get a new record created for MidYear table whenever I add a record in Student_table.
example
(When I create a new student it generates ID in studenttable and I want a blank record created in MidYear table that matches the new studentID)
-
May 3rd, 2006, 09:47 AM
#4
Re: linked table help
Do both INSERTS together (assuming you are using code to create records).
-
May 3rd, 2006, 11:21 AM
#5
Thread Starter
Lively Member
Re: linked table help
how would I get it to delete both records if student is deleted?
If student 1 is student_table is deleted student 1 records in midyear_table are also deleted
-
May 3rd, 2006, 11:41 AM
#6
Re: linked table help
Originally Posted by graphixphantix
how would I get it to delete both records if student is deleted?
If student 1 is student_table is deleted student 1 records in midyear_table are also deleted
What is the one thing they both have in common?
-
May 3rd, 2006, 12:57 PM
#7
Thread Starter
Lively Member
Re: linked table help
This is what I wrote but it's not working right
VB Code:
If MsgBox("Are you sure you want to delete this record?", vbYesNo + vbQuestion, "Delete?") = vbNo Then 'check if you really want to delete this record
Exit Sub 'exit the command
Else
If Not (rs.BOF = True Or rs.EOF = True ) Then
'delete the current record
rs1.Delete: rs.Delete
If Not (rs.BOF = True Or rs.EOF = True) Then
rs.MoveNext 'move next
If rs.EOF Then rs.MoveLast
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|