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

MS Access VBA

Status
Not open for further replies.

sysadmin07

IS-IT--Management
Feb 20, 2007
41
0
0
US
Hi,

Within Access, I have some data in a table that I'd like to use to selectively populate another table. Per the example table below, I'd like to dump all data into another table, although where the State is equal to California, I'd like to only populate the values where LName is equal to Smith. So, for example, James Smith, Tom Smith, and Frank Williams would reside in the new table. However, Jane Doe would not because State equals California and LName does not equal Smith. I'm having some trouble finding a way to use SQL or VBA to perform this.

Thanks

FName LName City State
James Smith Los Angeles California
Tom Smith San Francisco California
Jane Doe Sacramento California
Frank Williams Daytona Beach Florida
 
SQL code:
INSERT INTO newTable (FName, LName, City, State)
SELECT FName, LName, City, State
FROM oldTable
WHERE LName = 'Smith' OR State <> 'California'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top