mail merge from converted 97 db (1 Viewer)

Moira Triance

Registered User.
Local time
Today, 03:55
Joined
Sep 27, 2001
Messages
16
Hi
I had some very useful help last week from Marion in converting an Access 97 db to 2002. Now my problem has moved on as I am trying to convert the mail merge code in the same db so that when I click on a command button it merges 1 record from a query with a letter. Sounds simple, but I have studied the previous posts on this topic and can't see why my code is wrong.
The error I am getting is "Invalid SQL Statement; expected 'Select', 'Delete', Insert' etc. I have used Debug to narrow this down to one statement, which is:

' Open a recordset based on the qStudentAcceptLetter query.
rstStudent.Open " qStudentAcceptLetter ", _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic

I modified this code from the Access 2002 VBA step by step book and it works fine in the training example but not in the converted DB.
Any help VERY greatly appreciated. This is driving me crazy!:(
I have attached the whole sub as a txt file
 

Attachments

  • private sub printal.txt
    3.7 KB · Views: 456

Travis

Registered User.
Local time
Yesterday, 19:55
Joined
Dec 17, 1999
Messages
1,332
I have looked at your code and I don't believe that is the problem.

Look at your query "qStudentAcceptLetter".

Answer These Questions:

1. Does qStudentAcceptLetter exist?
2. Is qStudentAcceptLetter a Select query or an Action Query? (You want it to be a select in this case)
3. Can I open this Query outside of the code?
 
Last edited:

Moira Triance

Registered User.
Local time
Today, 03:55
Joined
Sep 27, 2001
Messages
16
Thanks for the suggestion Travis. I had also started to doubt my own eyes but, yes the query does exist, it is a select query and it does run. This db is one I had to convert from 97 and the original developer put in a lot of code at startup and I wonder if that is causing a problem. I have attached the startup function as a text file. In the meantime I am going to try disabling the start up function and see if that helps with the problem as I am on a deadline. Thanks for you help.
 

Users who are viewing this thread

Top Bottom