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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a Table with a Parameter Query

Status
Not open for further replies.

Brogrim

Technical User
Jul 28, 2000
184
IE
I have a table with about 500 records, the table is used for mailing purposes only. There is a Yes/No Field which if ticked to true mean's the record is on the mailing list.

I want to be able to save a selected list of records for future use. I thought I could do it with a make table query but I does'nt allow me to name the table.

I have tried the following code

SELECT tblMember.MemberID, tblMember.Mailout INTO [Enter a name for the New Table]
FROM tblMember
WHERE (((tblMember.Mailout)=-1));

It created a table called Enter a name for the New Table
 
There are restrictions on how parameters may be used in an SQL statement. You can use them to supply data values but not field names, table names, operators or SQL predicates. To do this you would need to construct the statement in code ; save it as a query and then execute it. Something like
Code:
Dim SQL As String

SQL = "SELECT tblMember.MemberID, tblMember.Mailout INTO " & _
      InputBox("Enter a Name for the New Table") & " " & _
      "FROM tblMember " & _
      "WHERE (((tblMember.Mailout)=-1)); "
Then save as a query and execute.

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top