Re: ADO Function Needed
From: ScottShell (ScottRShell_at_comcast.net)
Date: 09/29/04
- Previous message: ScottShell: "Re: Calling SP from ADO and passing parameters"
- In reply to: Toco: "ADO Function Needed"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 28 Sep 2004 21:44:03 -0700
If all you need is the record count, you could try
SET rstOne = CurrentProject.Connection.Execute("SELECT COUNT(custID) FROM
tbCustomerLetters")
and then have the SELECT CASE... structure below that, so you only execute
it one time.
Or, could you just move the recordset code above the SELECT CASE, and assign
the RecordCount property to a local variable?
"Toco" <Toco@discussions.microsoft.com> wrote in message
news:D65581CA-6082-4739-8C09-99E4F11D7AE2@microsoft.com...
> Hello. I have an ADO statement that executes the same query, in the body
of
> a case statement. I seem to repeat the same ADO call because the
> .RecordCount is dynamic, even though the actual SQL is the same. My goal
is
> to create a function that executes the query, opens the recordset, then
> returns a .RecordCount. Is it possible to implement this using a
Function,
> that uses the .RecordCount as the return value? That way I can call the
> function from within the case statements? As it stands now I have dimmed
> about 5 different strSQL and rstCounts, all within one Select Case
statement.
> This is very unmanaged, spaghetti code I have going. Here is the ADO
> procedure I have repeated 5 times for every case option
>
> Dim strSQL1 As String, rstOne As New ADODB.Recordset
> strSQL1 = "Select custID from tbCustomerLetters"
> rstOne.Open strSQL1, CurrentProject.Connection, adOpenStatic,
> adLockReadOnly
> With rstOne
> If .RecordCount = 0 Then
> MsgBox "No customers were processed in your query", 64
+
> 0, "No Letters printed"
> GoTo ExitPrint
> End If
> If MsgBox("Continue?", vbYesNo, "There are " &
.RecordCount
> & " Letters to be printed ") = vbYes Then
> Call PrintReport("rptCustomerLetter")
> Else
> rstOne.Close
> End If
> End With
>
> Next Case Statement---
>
> Toco
>
>
>
- Previous message: ScottShell: "Re: Calling SP from ADO and passing parameters"
- In reply to: Toco: "ADO Function Needed"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|