Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Append Query in VBA runtime error 3061

Posted on 2008-10-03
5
Medium Priority
?
267 Views
Last Modified: 2013-11-27
Hi Everyone,

I don't know why this won't work:

Dim rs As Recordset

Set rs = CurrentDb.OpenRecordset("SELECT * FROM subPatientGoal WHERE patientID = " & Me.Text49 & " and goaldesc = " & Me.listGoals)

If rs.EOF Then
      DoCmd.OpenQuery "AppendGoals"
    Me.ListFinalGoal.Requery
Else
   MsgBox "This has already been added as a goal."
End If

rs.Close
Set rs = Nothing

Can anyone help me?  It's urgent!

Thanks
Jetera
0
Comment
Question by:jetera
[X]
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
  • 3
  • 2
5 Comments
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 22634584
Hello jetera,

What is the point of opening the recordset?  You're not actually doing anything with it.

Try declaring rs as DAO.Recordset, and changing the open line to:

Set rs = CurrentDb.OpenRecordset("SELECT * FROM subPatientGoal WHERE patientID = '" & Me.Text49 & "' and goaldesc = "' & Me.listGoals & "'")

Regards,

Patrick
0
 

Author Comment

by:jetera
ID: 22634655
I was using it as a check to see if there is already a record in the table.  

I used your syntax and that part works...thanks :)

Now the rs.eof is not recognizing that their are records...
I thought rs.eof=true meant that no records were returned?  Basically I am checking the table for two values before appending the record.  When I know there are records with those values, it is supposed to go to the "else" statement but it is not doing that.
0
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 22634883
jetera said:
>>I was using it as a check to see if there is already a record in the table.  

OK, I missed that :)

>>Now the rs.eof is not recognizing that their are records...

Before testing the EOF, try:

rs.MoveLast
rs.MoveFirst
0
 

Author Closing Comment

by:jetera
ID: 31502779
Thanks!
0
 

Author Comment

by:jetera
ID: 22635048
Thanks!!!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

636 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