Avatar of pdvsa
pdvsa
Flag for United States of America asked on

Error 3065 - Cant execute a Select Query

Experts,

What is Error 3065?  Not sure what is setting off the error if it Appends correctly.  

Thank you


Private Sub cmdNewProject_Click()

        On Error GoTo EH

    Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("select * from Projects where 1=0")

With rs
    .AddNew
    ![Created By] = Nz([TempVars]![CurrentUserID], 0)
    ![Status2] = 7
    ![Currency] = DLookup("CurrencyID", "tblCurrencyExchange", "[Currency] = '" & Me.txtCur & "'")
    ![ProjectNo] = Me.txtActivityCode
    ![Project Name] = "LC Ref: (delete it after appending if want): " & Me.txtLCRef & ", Project Name: " & Me.txtActivityDescription
    ![Start Date] = Date
    ![Notes] = "****APPENDED LC FROM CSM*****: " & Format(Date, "m\/d\/yyyy") & ", Beneficiary :" & Me.txtBeneficiary & ", Guarantor: " & Me.txtGtorDescrip
    .Update
End With

rs.Close
        CurrentDb.Execute "qryUpdateProjID_tblLC", dbFailOnError         CurrentDb.Execute "qryUpdateProjID_CSM2", dbFailOnError

        DoCmd.OpenForm "frmUpdateBU"
        Me.Refresh
    
    Exit Sub
    

EH:  'Add error handling here

    MsgBox "Error " & Err.Number & ": " & Err.Description

End Sub

Open in new window



Error3065
Microsoft Access

Avatar of undefined
Last Comment
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

8/22/2022 - Mon
mbizup

Temporarily remove/comment out this line to see exactly which line is failing:

     ' On Error GoTo EH

Open in new window


Click debug when you get the error message and post the line of code in your next comment.
ASKER CERTIFIED SOLUTION
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Dale Fye

Actually, Joe, there were two queries on that line (way out to the right) that might be at fault.

CurrentDb.Execute "qryUpdateProjID_tblLC", dbFailOnError        
CurrentDb.Execute "qryUpdateProjID_CSM2", dbFailOnError

So, either of those queries could be the "select" query.

If the OP is anything like me, he/she was testing one of the queries and changed it to a select, and then forgot to change it back to an Update query.
pdvsa

ASKER
<he/she was testing one of the queries and changed it to a select, and then forgot to change it back to an Update query.
==>that is exactly what I did.  I now understand the importance of naming a update qry with the word Update in the name. I found 2 more I forgot to change from a select.

thank you
Your help has saved me hundreds of hours of internet surfing.
fblack61
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

So ... then I was right ... a was my post ??
I pointed out first that you cannot Execute a select query.

ms
Dale Fye

pdvsa,

Agree with, Joe.  He is the one that pointed it out, I just piled on.  He should get these points.

Click "Request Attention", bottom right corner of your original post, and ask the moderators to reopen the question so that you can award points appropriately.
pdvsa

ASKER
Sorry about that Joe...I requested attention
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

Details, details :-)