Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to stop error

Status
Not open for further replies.
Sep 25, 2002
159
US
Hi everyone,

I have a problem with an dynamic SQL statement I've created. I allow the user to choose an option via a CHECKBOX on an ASP page and submit. On the action page I wrote an SQL statement whose WHERE clause is filled in by the option the user chooses. It works fine, unless the user chooses an option that does not exist in the database yet. Then, I get an error that says: Object required:''
The error occurs at the .open statement in my code below. How can I capture this error before it gets to this point? If I can figure that out, then I can write an If statement that says if error exists, bypass this connection code.

with actionSet
.ActiveConnection = actionsDB
.Source = mySQL
.Open
End with

below is my SQL statement:

mySQL = "SELECT getBarcelonaBestPerformerData.Component AS Component, Count(getBarcelonaBestPerformerData.[Issue ID]) AS NumberOfActions, Round(Avg(getBarcelonaBestPerformerData.DaysToClose)) AS DaysToClose, Round(Avg(getBarcelonaBestPerformerData.DaysLate)) AS DaysLate"

'FROM
mySQL = mySQL & " FROM getBarcelonaBestPerformerData"

'WHERE
mySQL = mySQL & " WHERE getBarcelonaBestPerformerData.Component = '" & Request.QueryString("component") & "'"
mySQL = mySQL & " GROUP BY getBarcelonaBestPerformerData.Component;"
 
Are you sure the Open is causing the error? Try use
Response.Write(mySQL)
so you can copy and paste the sql into an Access query window.

It is possible the recordset will not return any records so any following code that references the fields from the recordset may fail.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top