| re: how to pass recordset object to procedures/functions?
You got my point, know exactly where did wrong now, thanks
Jing.
"James Fortune" <jafortun@oakland.edu> wrote in message
news:a6ed3ce7.0407072305.7bd4e463@posting.google.c om...[color=blue]
> "JingleBEV" <n_quan@NOSPAMyahoo.com> wrote in message[/color]
news:<oy2Hc.31303$WM5.1418219@news20.bellglobal.co m>...[color=blue][color=green]
> > Hi all,
> > I am trying not to use global variable to maintain data consistency.[/color][/color]
Some[color=blue][color=green]
> > 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[/color][/color]
(type[color=blue][color=green]
> > mismatch).
> > how can I achieve it?
> >
> > Your help is appreciated.
> >
> > Jing.[/color]
>
> 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[/color] |