Getting Return from query

GAKEN

New Member
Joined
Feb 25, 2003
Messages
38
I am running the following statement:

Code:
    SQL = "if object_id('BA_REPORT_MASTER') is not null  PRINT 'True' ELSE PRINT 'False'"
    RGConnection.Execute (SQL)

How do I get the result back?
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi,

That doesn't look like an SQL expression to me but I could be wrong.

Function reportGen()

Dim db As Database
Dim rs As Recordset
Dim select_sql As String

select_sql = "select * from BA_Report_Master into NewTable where ((Not ([BA_Report_Master].Location) Is Null));

Set db = CurrentDb()
db.Execute (select_sql)

End Function

You should be able to run this like a sub. It should create a new table NewTable and populate it with the SQL listed above. I might be totally off what you're going for, but let us know.

HTH,
 
Upvote 0
Resolved!

I fixed this! Here is what I did:

Code:
CREATE procedure sp_BA_ReportExist

AS

if (object_id('BA_REPORT_MASTER') is not null)

  select 'True' as Answer

else
 
 select 'False'  as Answer

return 0
GO

I changed my stored procedure to return a recordset which allowed me to change my code to:

Code:
    SQL = "sp_BA_ReportExist"
    Set RGRecordSet = RGConnection.Execute(SQL)
    
    Do While Not RGRecordSet.EOF
        TableExists = RGRecordSet.Fields("Answer")
            RGRecordSet.MoveNext
    Loop


Basically I just wanted to know if that table was there so I could set defaults on a form when it was loaded.

Thanks for your help!

Ken
 
Upvote 0

Forum statistics

Threads
1,221,497
Messages
6,160,150
Members
451,626
Latest member
sukhman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top