calling a code from a module is not responding

currentdb

Registered User.
Local time
Today, 08:24
Joined
Jan 30, 2007
Messages
30
Hi all,

I have a form with 2 group options + command button. I wanted to call a second form. It can work, but the second form must remain open. Then I placed the code (of form A and B) in a module. It still don't work and I don't know what else to do.

Anyone has any idea ?
 

Attachments

Last edited:
Post a copy of the database (stripped down if needed) then someone will take a look.
 
db uploaded.

To get a better idea how it works, you can go to the form frmCriteria which does the select records and move them to a temp table.
Then the second form, merge 3x which does the merge from Access to Word.

I wanted to combine both in a single one, hence that's why I put the code in a module (mdTransfer). I actually created a test form, name Criteria2 which calls the module mdTransfer, but after select records are moved to temp table, the progress bar remains at 0% and nothing is in the output folder.

Thanks
 
I have looked at the code and noted you haven't included the word Fields after each rs, I adjusted that and once I ran the Merge 3x it seemed to work.

Name = StrConv(rs.Fields("NAME"), vbProperCase)
Address = ProperCase(rs.Fields("ADDRESS"))
CITY = StrConv(rs.Fields("CITY"), vbProperCase)
STATE = rs.Fields("STATE")
ZIP_CODE = rs.Fields("ZIP_CODE")
NO_FILE = rs.Fields("NO_FILE")
AGENT = rs.Fields("AGENT")
NO_PHONE_AGENT = rs.Fields("NO_PHONE_AGENT")
 
Hi Trevor,

Adding the Fields to the rs or not, they work because they refer to bookmarks fields in Word.

But the main problem is how to run the code from the module. You may look in the mdTransfer and notice that I took most of the code from merge 3x and put it there, then placed a Call function in the form Criteria2.
 
I adjusted the Public Function as follows:

Function Transfer1()

I took out the comment in the Criteria 2 form and called the Transfer1

I then looked at the query and adjusted this to run something

INSERT INTO Tb_1stRenewalTMP ( NO_FILE, EXP_DATE, [LANGUAGE], Pmt, EXP_DATE )
SELECT ASSURVAR1.NO_FILE, ASSURVAR1.EXP_DATE, ASSURVAR1.LANGUAGE, ASSURVAR1.Pmt, ASSURVAR1.EXP_DATE
FROM ASSURVAR1
WHERE (((ASSURVAR1.EXP_DATE)>=Date()-30 And (ASSURVAR1.EXP_DATE)<=Date()) AND ((ASSURVAR1.LANGUAGE)="F"));

I then opened the form , it prompted me for something, so I used and your message box came up with "You have 8 french letters for the first renewal.

In the query you had duplicate fields for the Date so when the code ran it highlighted this, so I adjusted this as it wont append twice.

As it then continued it came up with a compile error, you can't assign to read only property and highlighted the name field in the VBA code.
 
Very hard to test without any sample templates from Word.
 
Trevor G / DCrake,

I added a sample Word template at the top of the post. It can help with the merge.
 
Trevor,
The query you quoted, normally it loops through records from the Assurvar1 table and select those with the date criteria, which is records in the past 30 days. What it does next is putting these records in a temp table (Tb_1stRenewalTMP). From there, the code that is in the second form (merge3x) has to look in this table and put & merge these records in a word template.

Hope that helps you understand better.
 
TableT does not contain all the fields you are referring to in your bookmarks.

Put a breakpoint on the

With WordObj.Selection

Line and step though using F8
 
True, I had to suppress sensitive information, that's why. You can add something else and it will work.
 
DCrake,

I'm trying to add the code from merge3x form into frmCriteria2.
As it was not working, I thought it was better to call this code from a module (mdTransfer)

If you run frmCriteria2, it will work, except when we come to the module function. There is no compile error that happens, but what happens exactly is:
- Records are selected & moved to a temp table
- A progress bar appears to indicate that the merge to Word is in progress.

The problem comes from the progress bar (I think). It remains at 0% and the code from this progress bar is in frmProgBar. The merge3x does not call the code from frmProgBar, but it works (if everything runs from merge3x only).

To solve the problem, I added the code from the frmProgBar at the end of the module mdTransfer and placed a Call Progress to frmCriteria2. I thought it will solve the problem with the progress bar and make everything works, but it's not working.

Hence, I'm puzzled and I don't know what else to do :(
 
It is very hard to come up with a solution when important field have been removed from tables. Take out all you error suppression and run to trap the errors. then Reinstate the error trapping
 
DCrake,

I added a revamped version of the database and added the missing fields. For the merge, you need to create 2 folders, In and Out. Put the word template in the In folder.

Now you can run the code without any other compile error (I hope so).
 

Users who are viewing this thread

Back
Top Bottom