Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

MS Access: Is it possible to ennoble 3061 error message?

Posted on 2014-10-08
7
135 Views
Last Modified: 2014-10-08
This simple vba code
Sub t()
    On Error Resume Next
    Debug.Print "1)", CurrentDb.OpenRecordset("select id      from table1")(0)
    If Err <> 0 Then Debug.Print Err, Err.Description
    Debug.Print "2)", CurrentDb.OpenRecordset("select id, x,y from table1")(0)
    If Err <> 0 Then Debug.Print Err, Err.Description
End Sub

Open in new window

returns the following in Immediate Window
1)             5 
 3061         Too few parameters. Expected 2.

Open in new window

Q): Is there a way to extend somehow the output to, say,
1)             5 
 3061         Too few parameters. Expected 2 ([x],[y])

Open in new window

Although it is irrelevant to the question I illustrate it with a "live" example.
Actual SQL code is programmatically generated and is about 1,500 characters long:
?len(stAnoQrysql)
 1572 

Open in new window

0
Comment
Question by:midfde
  • 4
  • 3
7 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 40368774
No, the err.description property is all you can get.

 There are times with ODBC when it will generate multiple errors and you need to loop through the errors collection to get them, but whatever is in the description property is what you get.

 There is no "verbose" mode.

Jim.
0
 
LVL 1

Author Comment

by:midfde
ID: 40368910
I've got the point. Just to make sure there is no misunerstanding. I did not mean anything like "verbose" mode. What I meant was whether VBA can interrogate MS Access about something it "knows", and I want the user know it too.
"MS Access knows" means that it can display what I want, and it does not want to pass it to my code  see the image.Access displays the name it cannot "recognize"
0
 
LVL 57
ID: 40368955
<<"MS Access knows" means that it can display what I want, and it does not want to pass it to my code  see the image. >>

  Yes it indeed does, but understand that "Access" is really three things; Access (MSACCESS.EXE) and the UI it presents along with the Access objects (like forms and reports),  A DB Engine (JET or ACE) and VBA.

 The parameter dialog you showed is coming out of MSACCESS.EXE.   But when your running code in VBA, that's out of the picture.  Only things involved at that point are VBA and the DB Engine.

 So when your executing queries in code, everything is up to you and that includes ensuring that the SQL statement is correct and resolving any parameters before hand.

 So if you had the the SQL in a querydef, you would open the querydef, loop through the parameters, and try to resolve each.  If you could not resolve one, then you would know which one was the problem and at this point, you could produce a dialog like MSACCESS.EXE does.

 To put that another way, if Access handed off a SQL statement to the DB engine without prompting you, you would get the same error from it "Too few parameters. Expected 2"  because all the DB engine is reporting back is that it can't execute the statement.

Jim.
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 1

Author Comment

by:midfde
ID: 40369144
I just wanted to inquire if anybody knows how to ask a right guy (of the three aforementioned, I think it's DB Engine) a right question.
0
 
LVL 57
ID: 40369193
From your comment, I'm not sure exactly what your asking for, but your question was:


Q): Is there a way to extend somehow the output to, say,

To which the short answer is no.

Jim.
0
 
LVL 1

Author Comment

by:midfde
ID: 40369689
I've requested that this question be closed as follows:

Accepted answer: 0 points for midfde's comment #a40369144

for the following reason:

Thanks for you attention Jim.
0
 
LVL 1

Author Closing Comment

by:midfde
ID: 40369690
Thanks for your attention Jim.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question