Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Stored Procedure in ADP

Status
Not open for further replies.

cmarch1

MIS
Apr 5, 2001
41
US
I have a main form that once logged in, the user selects their options through command buttons. I have passed the ProgramID with the user information after logging in and have even placed the ProgramID in a text box hidden on the main form(txtUProgID). Depending on who is logged in the correct ProgramID shows up. But I'm having a problem with filtering the once form to show the user only records belonging to their program. Below is a copy of the procedure in Access and the stored procedure in SQL. I get a message that the object doesn't support this property or method and have changed my code a billion times with the same results..Any help appreciated.

Private Sub cmdProjects_Click()
MsgBox "Got there", vbOKOnly
If IsJoeUser() Then
If gcfHandleErrors Then On Error GoTo Proc_Err
Dim rs As ADODB.Recordset
Dim arrPrms(0 To 0, 1 To 2) As Variant

Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
MsgBox "Got there2", vbOKOnly

arrPrms(0, 1) = "@UProgID"
arrPrms(0, 2) = txtUProgID

MsgBox "Got there3", vbOKOnly
If CreateRecordsetFromStoredProc(rs, "ProjectRecords", arrPrms()) Then
MsgBox "AfterProcedure", vbOKOnly
If Not rs.EOF Then
MsgBox "Before Recordset", vbOKOnly
Set Forms.frmProject.Recordset = rs
MsgBox "After Recordset", vbOKOnly
Else
MsgBox "No records found", vbInformation
End If
Else
MsgBox "No records found", vbInformation
End If
End If

MsgBox "error", vbOKOnly
If gcfHandleErrors Then On Error GoTo Proc_Err
DoCmd.OpenForm "frmProject"

Proc_Exit:
Exit Sub

Proc_Err:
Call ErrHandler("Form_" & Me.Name, "")
Resume Proc_Exit

End Sub



CREATE PROCEDURE ProjectRecordsold
(
@UProgID int = null
)
AS
Set NoCount ON
Declare @strSQL varchar(255)
Declare @strW varchar(255)
Declare @qt varchar(1)
/*qt =just in case I needed spaces in select statement*/

Select @qt =''
Select @strW =''
Select @strSQL = 'Select * from Project'

If @UProgID is not null
Select @strW = 'ProgramID =' + Convert(Varchar, @UProgID)

If @strW <> ''
Select @strSQL= @strSQL + ' Where ' + @strW

Exec(@strSQL)

Return(0)








 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top