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!

dynamic SQL based on form recordSource

Status
Not open for further replies.

JoshuaAnthony

Programmer
Dec 17, 2003
20
0
0
AU
Hi,

This code works for me:

strSQL = "SELECT * FROM [" & Me.RecordSource & "]"

But I can't seem to select certain fields from the recordSource. This is one of my attempts that failed:

strSQL = "SELECT [" & Me.RecordSource.[ID Number] & "], [" & Me.RecordSource.[Field1] & "] FROM [" & Me.RecordSource & "]"

Any suggestions to set me in the right direction?

Thanks,

Joshua
 
What is the purpose of your SQL, how are you going to use it?

Alec Doughty
Doughty Consulting P/L

"Life's a competition. Play hard, but play fair"
 
It was for exporting the dynamic recordSource of a form to an Excel file.

Somebody has actually suggested something in another forum (I was desperate for an answer!) that worked:

strSQL = "SELECT [ID Number], [Field1] FROM [" & Me.RecordSource & "]"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top