Solved

Append Query in VBA runtime error 3061

Posted on 2008-10-03
5
255 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
  • 3
  • 2
5 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
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
Comment Utility
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 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
Comment Utility
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
Comment Utility
Thanks!
0
 

Author Comment

by:jetera
Comment Utility
Thanks!!!!
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.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

772 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

10 Experts available now in Live!

Get 1:1 Help Now