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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 3146

Status
Not open for further replies.

AT76

Technical User
Apr 14, 2005
460
US
Could someone offer some help with this error I keep getting. It seems to be when it code tries to execute the Store Procedure. See below in bold. I get the error when it tries executing it but if I hit END after the error the code executes OK. Is there a way to ignore this error? Any suggestions? Thanks!!!

Private Sub Form_Load()

'On Error GoTo Err_Onload_Click

Dim MyMonth As Integer
Me.AIM_FORECAST.Visible = False

bFrmLoaded = False

'open a connection to SQLServer and get the data from the database
Set wrkODBC = CreateWorkspace("ODBCWorkspace", _
"", "", dbUseODBC)

Set conMaterialsDB = wrkODBC.OpenConnection("", _
dbDriverNoPrompt, , _
"ODBC;DATABASE=DatabaseName;FileDSN=//.../DSNNAME.dsn;Trusted_Connection=Yes")

strPartNumber = Forms![FRM_Main]![ITMID]
Set qryNotes = conMaterialsDB.CreateQueryDef("", "execute pc_select_fcst_notes '" & strPartNumber & "'")
Set rstNotes = qryNotes.OpenRecordset(dbOpenSnapshot)

If rstNotes.EOF = False Then

Set ctrl = Me.CB_FCST_Notes
ctrl.RowSourceType = "Value List"
rstNotes.MoveLast
rstNotes.MoveFirst
iCount = rstNotes.RecordCount

If (iCount > 1) Then
strFirstNote = Format(rstNotes!FCSTDTE, "Short Date") & " " & Mid(rstNotes!PLNRNAME, 11) & " - " & Trim(rstNotes!FCSTNOTE)
ctrl.SetFocus
ctrl = strFirstNote
rstNotes.MoveNext

While (rstNotes.EOF = False)
strNotes = strNotes & " " & Format(rstNotes!FCSTDTE, "Short Date") & " " & Mid(rstNotes!PLNRNAME, 11) & " - " & Trim(rstNotes!FCSTNOTE) & ";"
rstNotes.MoveNext
Wend
ctrl.RowSource = strNotes
End If

If (iCount = 1) Then
strFirstNote = Format(rstNotes!FCSTDTE, "Short Date") & " " & Mid(rstNotes!PLNRNAME, 11) & " - " & Trim(rstNotes!FCSTNOTE)
ctrl.SetFocus
ctrl = strFirstNote
End If

End If
iCount = 0
wrkODBC.Close
Set wrkODBC = Nothing
Me.Command256.SetFocus

'Exit Sub
'Err_Onload_Click:
' MsgBox Err.Description
' Resume

End Sub
 
I don't know, if it's my unfamiliarity with the technique
you used to open a recordset, or it's not permissable.


judging by the error "Application-defined or object-defined error",
I'd say, not permissable?

but, why wouldn't you in the first place, use
the conventional method, especially since you're not
saving the Query?

Set rstNotes = conMaterialsDB.OpenRecordset("execute pc_select_fcst_notes '" & strPartNumber & "'", _
dbOpenSnapshot)

...excuse the syntax if uncorrect, i haven't used dao for some time.

Also, clicking "End", terminates the program, at
the point of error, how can it run fine???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top