Open multiple files (1 Viewer)

mlopes1

Registered User.
Local time
Today, 14:21
Joined
Sep 4, 2002
Messages
76
I have a form where a user can select anywhere from 1 to 20 "products" (1 at a time). Once they select a product from the combo box and click the "add product" button, the item is added to a sub form that acts kind of like a shopping cart.

One of the options then becomes for them to View the product details. The details are found in each product's associated Word file. Based on a seperate table, when the user selects the product, it's file path name is stored.

SO, now I have a table filled with 1 to 20 paths (C:/Files/Product1.doc... etc) I can succesfully open one file using: Call Shell(stAppName, 1) where stAppName is defined by the path above. But what I can't figure out is how to open all the files if the user selects multiple products. They can be opened all at once, it doesn't matter. I just don't know how to loop through table (Products_Slct) records and call each path.

How do I move record to record and pull out the path names?

Thanks as always,

Marco
 

jaydwest

JayW
Local time
Today, 11:21
Joined
Apr 22, 2003
Messages
340
Open Multiple Files

If you want to step thru and open the files one at a time try the folllowing code.

Dim rst as DAO.Recordset

set rst = Me![SubformFieldName].Form.RecordsetClone
Do until rst.EOF
strAppName = rst!Appname
Call Shell(stAppName, 1)
Loop

The RecordsetClone provides the subform's underlying recordset.

Hope this helps.
 

mlopes1

Registered User.
Local time
Today, 14:21
Joined
Sep 4, 2002
Messages
76
I keep receiving a type mismatch error using the following code:

Dim rst As dao.Recordset

Set rst = Me![Formula_Number].Form.RecordsetClone
Do Until rst.EOF
stAppName = rst!appname
Call Shell(stAppName, 1)
Loop

It breaks right at the 2nd line.

I am absolutely sure that Formula_Number is the field name. Could this be because its on the subform and not the main form? Or am I missing something even more obvious?! Also, I noticed that the dao in the dim line did not capitalize itself... does this mean I am missing this function or something of the sort?

Thanks again for your help... I am definitely closer to the solution!
 

jaydwest

JayW
Local time
Today, 11:21
Joined
Apr 22, 2003
Messages
340
Open Multiple Files

The Subform Name is a little tricky. It's not the SourceObject of the Subform Control. Its the name of the control. Click once on the edge of the Subform Control. If the little black box (select Box) appears in the upper left, you've selected the Subform not the Control. You should have small black selection handles on the control on its edge.

If you click on the edge of the control, right click to display the properties popup and then click on the Other Tab. The first line is Name. Enter the name of the Subform Control here. Use as short name, as you're have to type it in whenever refering to it. So if the Subform Source Oject is named frm)InvoicePayment_Subform we would name the Control something like PaymentSubform.

Let me know if this works.
 

mlopes1

Registered User.
Local time
Today, 14:21
Joined
Sep 4, 2002
Messages
76
Jay,

You were right.. I was looking at the wrong set of properties! But, looking at your original solution, I don't see where the sub form name comes into play? You had :
set rst = Me![SubformFieldName].Form.RecordsetClone

So I coded:

set rst = Me![Formula_Number].Form.RecordsetClone
where Formula_Number is the field name, not sub form name.

So after your 2nd pointer I changed it to:

Set rst = Me![COA_Select_SF]![Formula_Number].Form.RecordsetClone

AND replacing the first ! with a . :

Set rst = Me.[COA_Select_SF]![Formula_Number].Form.RecordsetClone

where COA_Select_SF is now the correct Name as found using your previous answer. I still get type mismatch... is there something wrong with this new syntax? Obviously there is but I am not seeing it!! Thanks again
 

jaydwest

JayW
Local time
Today, 11:21
Joined
Apr 22, 2003
Messages
340
Open Multiple Files

Sorry, I forgot the movenext. Loop should look something like this.

Do Until rst.EOF
...
rst.MoveNext
Loop

I must have a mental block with MoveNext.

Also. I have noticed that sometimes DAO is not automatically capitalized. It doesn't seem to make a difference. However, we try to type it in in CAPS anyway.
 

jaydwest

JayW
Local time
Today, 11:21
Joined
Apr 22, 2003
Messages
340
Open Multiple Files

I think you still have the syntax wrong. should be

Set rst = Me![COA_Select_SF].Form.RecordsetClone

If [COA_Select_SF] is the Control Name, or

Set rst = Me![Formula_Number].Form.RecordsetClone

if [Formula_Number] is the Control Name.
 

mlopes1

Registered User.
Local time
Today, 14:21
Joined
Sep 4, 2002
Messages
76
That was it...

You were right that DAO didn't matter and also I was combining the syntax incorrectly.

Thanks again!!
 

Users who are viewing this thread

Top Bottom