By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,143 Members | 1,855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,143 IT Pros & Developers. It's quick & easy.

how to pass recordset object to procedures/functions?

P: n/a

Hi all,
I am trying not to use global variable to maintain data consistency. Some
procedures and functions will require to pass the recordset object for
processing and functions may also return the recordset object to the
calling
functions/procedures. I already tried this but keep getting error 13 (type
mismatch).
how can I achieve it?

Your help is appreciated.

Jing.


Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Show us your code?

Make sure that your ADO recordset declarations are not confused with your
DAO recordset declarations.

(DAVID)

"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:oy*********************@news20.bellglobal.com ...

Hi all,
I am trying not to use global variable to maintain data consistency. Some
procedures and functions will require to pass the recordset object for
processing and functions may also return the recordset object to the
calling
functions/procedures. I already tried this but keep getting error 13 (type mismatch).
how can I achieve it?

Your help is appreciated.

Jing.

Nov 13 '05 #2

P: n/a
"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message news:<oy*********************@news20.bellglobal.co m>...
Hi all,
I am trying not to use global variable to maintain data consistency. Some
procedures and functions will require to pass the recordset object for
processing and functions may also return the recordset object to the
calling
functions/procedures. I already tried this but keep getting error 13 (type
mismatch).
how can I achieve it?

Your help is appreciated.

Jing.


It would look something like:
Public Function FillSearchResultsEditForm(MyRS As Recordset, strCrit
As String, strError As String) As Boolean

It would be used something like:
Private Sub cbxChargeDate_AfterUpdate()
....
If UpdateRowsources("cbxChargeDate", strFinalSearchSQL) Then
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset(strFinalSearchSQL, dbOpenSnapshot)
strError = ""
strCrit = "[TimeTicketID] Is Not Null"
If MyRS.RecordCount > 0 Then
MyRS.MoveLast
lngCount = MyRS.RecordCount
'Always show the first record that matches the criteria
'This is the call: <=================================
If FillSearchResultsEditForm(MyRS, strCrit, strError) Then
Call ShowNavButtons
txtOf.Value = lngCount
txtMatchLoc = 1
End If
MyRS.Close
Set MyRS = Nothing
End If
Else
Call HideNavButtons
MsgBox ("No records were found matching selections. You should
start the search over.")
End If
....

I passed in MyDB As Database but never used it (I think). Also, the
form filled above uses unbound controls so the dbOpenSnapshot mode is
O.K. for this situation. The first parameter of the UpdateRowsources
subroutine is only to let the subroutine know which combobox caused
the change. It actually changes the Rowsources of all affected
comboboxes. Note: In this example the code is behind the form rather
than in a module.

James A. Fortune
Nov 13 '05 #3

P: n/a
You got my point, know exactly where did wrong now, thanks

Jing.
"James Fortune" <ja******@oakland.edu> wrote in message
news:a6**************************@posting.google.c om...
"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message

news:<oy*********************@news20.bellglobal.co m>...
Hi all,
I am trying not to use global variable to maintain data consistency. Some procedures and functions will require to pass the recordset object for
processing and functions may also return the recordset object to the
calling
functions/procedures. I already tried this but keep getting error 13 (type mismatch).
how can I achieve it?

Your help is appreciated.

Jing.


It would look something like:
Public Function FillSearchResultsEditForm(MyRS As Recordset, strCrit
As String, strError As String) As Boolean

It would be used something like:
Private Sub cbxChargeDate_AfterUpdate()
...
If UpdateRowsources("cbxChargeDate", strFinalSearchSQL) Then
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset(strFinalSearchSQL, dbOpenSnapshot)
strError = ""
strCrit = "[TimeTicketID] Is Not Null"
If MyRS.RecordCount > 0 Then
MyRS.MoveLast
lngCount = MyRS.RecordCount
'Always show the first record that matches the criteria
'This is the call: <=================================
If FillSearchResultsEditForm(MyRS, strCrit, strError) Then
Call ShowNavButtons
txtOf.Value = lngCount
txtMatchLoc = 1
End If
MyRS.Close
Set MyRS = Nothing
End If
Else
Call HideNavButtons
MsgBox ("No records were found matching selections. You should
start the search over.")
End If
...

I passed in MyDB As Database but never used it (I think). Also, the
form filled above uses unbound controls so the dbOpenSnapshot mode is
O.K. for this situation. The first parameter of the UpdateRowsources
subroutine is only to let the subroutine know which combobox caused
the change. It actually changes the Rowsources of all affected
comboboxes. Note: In this example the code is behind the form rather
than in a module.

James A. Fortune

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.