Compile error

mac_see

Active Member
Joined
Oct 15, 2002
Messages
419
I have a table [Table1] and only ten field [Field1],[Field2]... so on with 12 records in each field.

I have a make table query after running which, I get 66 records into a new table. This query basically makes all possible combinations of all 12 records in Field1. I want to do this task for all the 10 fields so I thought of writing a code but it gives me compile errors and too many space continuation.

Dim I As Integer
Dim strSQL As String
For I = 1 To 10
strSQL = “HERE IS THE PROBLEM"
Next...
End

Here is the SQL:

SELECT Table1.Field1 & "," & Table1_1.Field1 & "," & Table1_2.Field1 & "," & Table1_3.Field1 & "," & Table1_4.Field1 & "," & Table1_5.Field1 & "," & Table1_6.Field1 & "," & Table1_7.Field1 & "," & Table1_8.Field1 & "," & Table1_9.Field1 AS Expr1, Table1.Field1+Table1_1.Field1+Table1_2.Field1+Table1_3.Field1+Table1_4.Field1+Table1_5.Field1+Table1_6.Field1+Table1_7.Field1+Table1_8.Field1+Table1_9.Field1 AS Expr2 INTO NewTable
FROM Table1, Table1 AS Table1_1, Table1 AS Table1_2, Table1 AS Table1_3, Table1 AS Table1_4, Table1 AS Table1_5, Table1 AS Table1_6, Table1 AS Table1_7, Table1 AS Table1_8, Table1 AS Table1_9
WHERE (((Table1_1.Field1)>[Table1].[Field1]) AND ((Table1_2.Field1)>[Table1].[Field1] And (Table1_2.Field1)>[Table1_1].[Field1]) AND ((Table1_3.Field1)>[Table1].[Field1] And (Table1_3.Field1)>[Table1_1].[Field1] And (Table1_3.Field1)>[Table1_2].[Field1]) AND ((Table1_4.Field1)>[Table1].[Field1] And (Table1_4.Field1)>[Table1_1].[Field1] And (Table1_4.Field1)>[Table1_2].[Field1] And (Table1_4.Field1)>[Table1_3].[Field1]) AND ((Table1_5.Field1)>[Table1].[Field1] And (Table1_5.Field1)>[Table1_1].[Field1] And (Table1_5.Field1)>[Table1_2].[Field1] And (Table1_5.Field1)>[Table1_3].[Field1] And (Table1_5.Field1)>[Table1_4].[Field1]) AND ((Table1_6.Field1)>[Table1].[Field1] And (Table1_6.Field1)>[Table1_1].[Field1] And (Table1_6.Field1)>[Table1_2].[Field1] And (Table1_6.Field1)>[Table1_3].[Field1] And (Table1_6.Field1)>[Table1_4].[Field1] And (Table1_6.Field1)>[Table1_5].[Field1]) AND ((Table1_7.Field1)>[Table1].[Field1] And (Table1_7.Field1)>[Table1_1].[Field1] And (Table1_7.Field1)>[Table1_2].[Field1] And (Table1_7.Field1)>[Table1_3].[Field1] And (Table1_7.Field1)>[Table1_4].[Field1] And (Table1_7.Field1)>[Table1_5].[Field1] And (Table1_7.Field1)>[Table1_6].[Field1]) AND ((Table1_8.Field1)>[Table1].[Field1] And (Table1_8.Field1)>[Table1_1].[Field1] And (Table1_8.Field1)>[Table1_2].[Field1] And (Table1_8.Field1)>[Table1_3].[Field1] And (Table1_8.Field1)>[Table1_4].[Field1] And (Table1_8.Field1)>[Table1_5].[Field1] And (Table1_8.Field1)>[Table1_6].[Field1] And (Table1_8.Field1)>[Table1_7].[Field1]) AND ((Table1_9.Field1)>[Table1].[Field1] And (Table1_9.Field1)>[Table1_1].[Field1] And (Table1_9.Field1)>[Table1_2].[Field1] And (Table1_9.Field1)>[Table1_3].[Field1] And (Table1_9.Field1)>[Table1_4].[Field1] And (Table1_9.Field1)>[Table1_5].[Field1] And (Table1_9.Field1)>[Table1_6].[Field1] And (Table1_9.Field1)>[Table1_7].[Field1] And (Table1_9.Field1)>[Table1_8].[Field1]));

Maxi
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Issue resolved !!!

I got it to work. There were problems with the " sign and some syntax. Thanx.
 
Upvote 0

Forum statistics

Threads
1,221,849
Messages
6,162,425
Members
451,765
Latest member
craigvan888

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top