Solved

Append Query in VBA runtime error 3061

Posted on 2008-10-03
5
259 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
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 92

Accepted Solution

by:
Patrick Matthews earned 500 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

756 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