[AccessD] Stored Proc AGAIN

Martin Reid mwp.reid at qub.ac.uk
Fri Jun 16 14:09:42 CDT 2006


Hers the first code I tired.
Its driving me nuts
 
Its simple. Stored Procedure, execute, set as recordset for a form.
 
I have noticed some odd things in the way 2007 is working with SQL Server 2005 but the basic idea here is just that basic and no matter what I have tried I cant get it to assign the recordset.
 
Any help appreciated. This is the last example I have to do so I jsut left it for the moment and moved on. 
 

Private Sub Form_Open(Cancel As Integer)

On Error GoTo Err_Form_Open

Dim rststudent As ADODB.Recordset

Dim conn As ADODB.Connection

Dim fld As ADODB.Field

Set conn = CurrentProject.AccessConnection

Set rststudent = New ADODB.Recordset

rststudent.ActiveConnection = conn

rststudent.Open "usp_GetStudentData", , , , adCmdStoredProc

If rststudent.EOF = True Then

MsgBox "No Student Data"

Exit Sub

Else

 

For Each fld In rststudent.Fields

                        Me(fld.Name).Value = fld.Value

Next

End If

 

Exit_Form_Open:

Exit Sub

Err_Form_Open:

        MsgBox Err.Description, , "Error in Sub Form_frmChapter6SPExample.Form_Open"

        Resume Exit_Form_Open

    Resume 0    '.FOR TROUBLESHOOTING

End Sub

 
Martin WP Reid
Training and Assessment Unit
Riddle Hall
Belfast
 
tel: 02890 974477
 
 


More information about the AccessD mailing list