Count Records from SQL

Randomblink

The Irreverent Reverend
Local time
Today, 16:15
Joined
Jul 23, 2001
Messages
279
Ok...
I have a function that gets passed a string...
The string contains SQL code...
SELECT statements only...

How do I count those records?
Due to the nature of the SQL, sometimes it will return NO records... sometimes it will return 0... and for some reason it treats them as two different results...

So, I am needing to test the SQL code...
On 0 or EMPTY I need to do one thing...
On 1 or greater returned records I need to do something else...

I have looked all over the help, searched online, and I have found nothing... Help if you can...
 
post code plz =) Should be quite simple tho...
 
What?!

Post what code?
In order for me to post everything that relates up to and including the Final Function, I would have several pages of explanations... so, for simplicity sakes this will have to do...

Code:
Public Function checkSQL(strSQL As String)

' This is why your question doesn't make sense...
' The whole function depends on HOW I can check the passed
' String through a sql function that tells me how many records
' there are in it...

End Function

My sql code differs at almost every call...
It is always a SELECT statement tho...

Basically, What I am doing is...
I have a SELECT statemtn already prepared for each Listbox I use... I do things to my forms that would make that SQL ask for PARAMETER VALUES since there are no records that match and the parameter value is currently set to an Autonumber field that has NO number entered...

So I am wanting to check the SQL query... If it returns bad or nothing, I do NOT want to use that code to attach it to the Listbox... I just wanna leave the listbox blank... If it DOES return records... then I want to set that SQL code to the listbox...

I hope that helps...
 
NEVER MIND!

Got it all worked out...
See, I store the RowSource for my Listboxes in their Tag as a string... The purpose being too convoluted to go into on one post... Anyway, for EVERY listbox on ALL my forms, I have ONE function that runs them...
For almost every form, I have one function for the OnCurrent event that sets the listbox rowsource to equal the tag... again, too convoluted to go into here... Whenever I delete something form my MAIN form, all subforms give me parameter value errors since the underlying subforms have listboxes whose criteria is based on fields on those subforms... So, I used a simple:

Criteria: Like <point to field on subform>
Criteria: <point to field on subform> Is Null

This way...
When I delete something from my MAIN form, the subform listboxes will not ask me for parameters... They just show everything... Which for now, works just fine... <chuckle>
 

Users who are viewing this thread

Back
Top Bottom