Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

macro/SQL error in Excel 1

Status
Not open for further replies.

amberH

Programmer
Jun 10, 2002
36
0
0
CA
Hi All,
I'm stumped.
I have recorded a couple macros for retrieving data from Access into Excel. They work fine as recorded.
The problem is this. I have a database with several lists of checkboxes. I have an excel sheet that pulls those checkboxes into a worksheet. When I record a macro, I pull all the fields in a query. When you view the VB of the macro, it lists each field individually. I need to say "take all fields" (i.e. *.*) so that if checkboxes are added to the database in the future, the VBA code in excel won't need to be changed in order to retrieve all data.
Anyways, I'm not sure what I'm doing wrong...but when I change my code, it won't work (I get a "General ODBC error").
Please help!!
My original code, that works is:

"SELECT CountOfPaperTests.Start_month, CountOfPaperTests.year, CountOfPaperTests.Paper_Basis_weight, CountOfPaperTests.Paper_Caliper, CountOfPaperTests.Paper_Tear_CD, CountOfPaperTests.Paper_Tear_MD, C" _
, "ountOfPaperTests.Paper_Mullen, CountOfPaperTests.Paper_Tensile, CountOfPaperTests.Paper_TEA, CountOfPaperTests.Paper_Stretch, CountOfPaperTests.Paper_Bright, CountOfPaperTests.Paper_A, CountOfPaperTes" _
, "ts.Paper_B, CountOfPaperTests.Paper_Opacity, CountOfPaperTests.Paper_NUI, CountOfPaperTests.Paper_Air_resistance, CountOfPaperTests.Paper_Top_smooth, CountOfPaperTests.Paper_Bottom_smooth, CountOfPape" _
, "rTests.Paper_TSO, CountOfPaperTests.Paper_Consistencies, CountOfPaperTests.Paper_CSF, CountOfPaperTests.Paper_Mutek, CountOfPaperTests.Paper_Turbidity, CountOfPaperTests.Paper_PQM, CountOfPaperTests.P" _
, "aper_Gap, CountOfPaperTests.Paper_Smith_needle, CountOfPaperTests.Paper_Gas, CountOfPaperTests.Paper_Press, CountOfPaperTests.Paper_Paprican, CountOfPaperTests.Paper_Customer_comparison, CountOfPaperTests.Paper_Shive_analysis" & Chr(13) & "" & Chr(10) & "FROM `E:\Projects\Jan Specker\Job Evaluation Data`.countFOPaperTests CountOfPaperTests")

my edited code (that won't work) is:

.CommandText = "SELECT *.*" & Chr(13) & "" & Chr(10) & "FROM `E:\Projects\Jan Specker\Job Evaluation Data`.countOfPaperTests CountOfPaperTests"

Any obvious errors I'm making??
THANKS!
amber
 
Try:

"SELECT *" & Chr(13) & "" & Chr(10) & "FROM `E:\Projects\Jan Specker\Job Evaluation Data`.countOfPaperTests CountOfPaperTests"

not *.*

Good Luck

Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top