G

#### Guest

and returns any checked columns from a table into an excel spreadsheet. I

got this far with at least the correct SQL statement.

'MY CODE SO FAR:

Private Sub Command87_Click()

Dim a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x

Dim selection As String

Dim SQL As String

If Partnercbox = True Then a = "Partner,"

If Locationcbox = True Then b = "Location,"

If Trackingcbox = True Then c = "Track,"

If ProjectSummarycbox = True Then d = "ProjectSummary,"

If SatisfyActcbox = True Then e = "SatisfyAct,"

If Voicecbox = True Then f = "Voice,"

If Datacbox = True Then g = "Data,"

If ECTemployeecbox = True Then h = "ECTEmployee,"

If Assistancecbox = True Then i = "Assistance,"

If Companycbox = True Then j = "Company,"

If Contactcbox = True Then k = "Contact,"

If Emailcbox = True Then l = "Email,"

If EndDatecbox = True Then m = "EndDate,"

If StartDatecbox = True Then n = "StartDate,"

If LastUpdateDatecbox = True Then o = "LastUpdateDate,"

If Phonecbox = True Then p = "Phone,"

If Requestcbox = True Then q = "Request,"

If Statecbox = True Then r = "State,"

If Statuscbox = True Then s = "Status,"

If StatusDesccbox = True Then t = "StatusDesc,"

If Techcbox = True Then u = "Tech,"

If TechDesccbox = True Then v = "TechDesc,"

If Productcbox = True Then w = "Product,"

x = "end"

selection = a & b & c & d & e & f & g & h & i & j & k & l & m & n & o & p &

q & r & s & t & u & v & w & x

If a = "" And b = "" And c = "" And d = "" And e = "" And f = "" And g = ""

And h = "" And j = "" And k = "" And l = "" And m = "" And n = "" And o = ""

And p = "" And q = "" And r = "" And s = "" And t = "" And u = "" And v = ""

And w = "" Then

MsgBox ("You must make at least one selection to Export")

Else:

'DoCmd.OutputTo acQuery, "qryExport", "MicrosoftExcel(*.xls)", "", True, "", 0

SQL = "SELECT " & selection & " FROM tbl-ECTprojects"

MsgBox (SQL)

'Returns the value "SELECT partner,location,end FROM tbl-ECTprojects" when

first two are checked which is good

DoCmd.RunSQL (SQL)

'DoCmd.RunSQL SQL, acCmdQueryAddToOutput, "qryExport", "MicrosoftExcel(*.xls)"

End If

End Sub 'End all code

Where I have my issue now is how to take that SQL statement and send the

result to a spreadsheet. I have no idea what to do and perhaps there is a

much better way to do this. I appreicate any help someone can give me.

Thanks in advance!