Solved

error 3061 expected 1 MS/ACCESS 2013

Posted on 2015-02-06
6
244 Views
Last Modified: 2016-02-11
I am running a query using the following code:

Private Sub Form_Load()
   
       
    Dim coreDB As DAO.Database

    Dim T00_ControlTableSet As DAO.Recordset, _
        Q32_DocumentoSelectSet As DAO.Recordset
       
    Dim Q32_DocumentoSelectDef As QueryDef
   
    Dim strPath As String, _
        strCorename As String, _
        strUserID As String, _
        strUserName As String
   
    Dim DocID As Integer
   
    Set coreDB = CurrentDb
    Set T00_ControlTableSet = coreDB.OpenRecordset("T00_ControlTable", dbOpenDynaset)
   
    DocID = Forms![F91_LoggedUser]![Fld_F91_DocID_Current]
    Me.Fld_F19_BaseDocID = DocID

    strPath = Nz(Forms![F91_LoggedUser]![F91_DestinationPathCurrent], "")
    strCoreID = Format(Forms![F91_LoggedUser]![CoreID], "0000")
    strUserName = Forms![F91_LoggedUser]![Fld_F91_NomeCompletoUtilizador]
    strUserID = Format(Forms![F91_LoggedUser]![CurrentUserID], "0000")
   
    Call LogMe("F19 Documento \ Load ", "CORE :" & strCoreID & "\ User: " & strUserID & "\" & strUserName _
                & " \ DocID: " & Me.Fld_F19_BaseDocID & " \ Path: " & strPath)
   
    strCoreID = Forms![F91_LoggedUser]![CoreID]
               
    ' selecciona o registo correto
    strSetSQL = "SELECT T25_DocsIpeme.T25_BaseDocID AS Q32_DocID, "
    strSetSQL = strSetSQL & "T25_DocsIpeme.T25_Titulo AS Q32_Titulo, "
    strSetSQL = strSetSQL & "T25_DocsIpeme.Sumario AS Q32_Sumario, "
    strSetSQL = strSetSQL & "T25_DocsIpeme.T25_DestinationPathXML  AS Q32_PathXML, "
    strSetSQL = strSetSQL & "T25_DocsIpeme.T25_DestinationPath AS Q32_Path "
    strSetSQL = strSetSQL & "FROM T25_DocsIpeme "
    strSetSQL = strSetSQL & "WHERE (((T25_DocsIpeme.T25_BaseDocID)= " _
                            & Me.Fld_F19_BaseDocID & ")); "
    MsgBox strSetSQL

On Error GoTo ErrorHandle:
    Set Q32_DocumentoSelectDef = coreDB.QueryDefs("Q32_DocumentoSelect")
    Q32_DocumentoSelectDef.SQL = strSetSQL
    Set Q30_DocumentoSelectSet = coreDB.OpenRecordset("Q32_DocumentoSelect", dbOpenDynaset)
    With Q30_DocumentoSelectSet
        Me.Fld_F19_Sumario = .Q32_Sumario
        Me.Fld_F19_Titulo = .Q32_Titulo
        Forms![F91_LoggedUser]![F91_DestinationPathCurrent] = .Q32_Path
        strPath = .Q32_Path
        Call LogMe("F19 Documento \ Document Record ", "CORE :" & strCoreID & "\ User: " & strUserID & "\" & strUserName _
                    & " \ DocID: " & Me.Fld_F19_BaseDocID & " \ Path: " & strPath)
    End With
    Exit Sub



ErrorHandle:
   'Problema no Query (vazio?)
    strError = Err & ": " & Error(Err)
    Call LogMe("F19 Documento \ DblClick \ ERROR \ " & strError & " \ ", "CORE :" & strCoreID & "\ User: " & strUserID & "\" & strUserName _
                & " \ File: " & strPath)
    MsgBox "Problema no acesso ao Documento; Possívelmente não existe em arquivo"
    Resume Next

   
End Sub


the query runs into the 3061 error:

Screen-Shot-2015-02-06-at-15.18.11.png

I have checked the table names and they look alright!

Can anyone help?
0
Comment
Question by:jirdeaid
  • 3
  • 2
6 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 40593566
Statement look OK, so I would check carefully for a mis-spelled field or table name.

One way to check that:

1. Execute your code and get the SQL statement
2. Copy it
3. Open a new query in design view.
4. Switch to SQL view
5. Paste the SQL string.
6. Edit out any extra characters
7. Switch to design view.

 Any fields that don't match up will end up as an expression and if you execute, will prompt for them if it can't figure it out.

Jim.
0
 
LVL 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 40593579
And BTW, if your just doing this in code, you can use a temp query def:

Set Q32_DocumentoSelectDef = coreDB.QueryDefs("")
Q32_DocumentoSelectDef.SQL = strSetSQL
Set Q30_DocumentoSelectSet = Q32_DocumentoSelectDef.OpenRecordset("Q32_DocumentoSelect", dbOpenDynaset)

Jim.
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 40593581
I guess this should read:

    Set Q30_DocumentoSelectSet = coreDB.OpenRecordset("Q32_DocumentoSelectDef", dbOpenDynaset)

/gustav
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

Author Closing Comment

by:jirdeaid
ID: 40593753
gee ... THANKS!
GHot the problem; actually it was a name of a column.... btw how do I accede/inspect to the  contents of a string in runtime without using the msgbox?
0
 
LVL 57
ID: 40593862
<<btw how do I accede/inspect to the  contents of a string in runtime without using the msgbox? >>

 Put a break point on the line and then hit F8 to step through it or place a stop right after.  Then you can either:

a. Hover over the variable and get the tool tip

b.  Bring up the debug window (Ctrl/G) and type:

?  <variable>

 so

?  strSQL

 I do it this way so you can see the full thing (don't always get that with a hover).

 ?  is short for Debug.Print

Jim.
0
 

Author Comment

by:jirdeaid
ID: 40594078
Thanks!
joao
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access Runtime 2010 Error 17 29
Tags from access to excel 3 24
change the windows script file to BAT 10 22
format date field on certain entries 8 22
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

947 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now