Advertisement

04.08.2008 at 07:15AM PDT, ID: 23304650
[x]
Attachment Details

How to Check If Query Returns Records

Asked by Tom_wbi in Access Reports, SQL Query Syntax

Tags: MS Access/VB

I have an MS Access Report with Unbound Text Boxes.  I have code that creates SQL Queries, stores them in array arguments (such as arr(1) as seen below) and then assigns the RESULT of that query to the text box for display on my Access report.

The following working line of code does this:

Me.Header0TextBox3.ControlSource = "=" & CurrentDB.OpenRecordset(arr(1)).Fields(0).Value

My question is that SOMETIMES the query that is stored in arr(1) returns NO Records, which is OK EXCEPT for the fact that if the Query returns no records and I attempt to assign the result of this query as above, I get a code violation.

I need to FIRST check that the resulting query stored in arr(1) returns something BEFORE I execute the above line of code.

Does anyone know how to do this?Start Free Trial
[+][-]04.08.2008 at 07:25AM PDT, ID: 21305554

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.08.2008 at 01:35PM PDT, ID: 21309315

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.09.2008 at 06:21AM PDT, ID: 21314545

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.09.2008 at 07:44AM PDT, ID: 21315427

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.09.2008 at 01:29PM PDT, ID: 21318756

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.09.2008 at 10:58PM PDT, ID: 21322037

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.09.2008 at 11:10PM PDT, ID: 21322087

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Reports, SQL Query Syntax
Tags: MS Access/VB
Sign Up Now!
Solution Provided By: frankytee
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.10.2008 at 12:52PM PDT, ID: 21328682

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.10.2008 at 01:27PM PDT, ID: 21329030

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628