Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 22nd, 2003, 11:55 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Append query problem

Hello everyone,

I know that you can use a variable in the WHERE part of SQL statement (as criteria), but can you insert variable data to a field as part of the same SQL statement ?

Vladimir
Australia
__________________
Vlad
Sydney, Australia
 
Old July 23rd, 2003, 01:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Short answer - YES.

There's heaps of different ways you can do it - whether it's a saved query, using recordsets, or plain old code to do it.

What is it that you're wanting to do?


There are 10 kinds of people in the world - those who understand binary - and those with friends
 
Old July 23rd, 2003, 06:26 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello everyone,

I'm posting the same problem on Access and Access VBA list, so here's the summary of the problem regarding the append query. I've "hit a wall" with this and not sure how to proceed, any opinion will be greatly appreciated.

My main table contains field TeamLeaderID as AutoNum, PK. Other fields are TeamLeaderName, Crew. The "child" table contains ID field as AutoNum, PK, TeamLeaderID link as LongInt and other fields. The 1 to many rel. is on TeamLeaderID and i have enforced all ref.integrity rules on the link.

When the user (new TeamLeader) carries over the jobs, he should go to entry form enter his details, then append non-complete jobs from previous day to subform. I think what is creating the problem is that previous days' jobs carry previous teamleader's ID link. If i append as it is, the jobs will remain linked to previous team leader. I need to find a way to append job details and insert new teamLeaderID for every appended job, so that data will show properly in both main and subform.


Vladimir
Australia
 
Old July 23rd, 2003, 07:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If I understand this correctly, this is what you're wanting to do:
Append records that are the same as existing records, but with a different TeamLeaderID. If this is right - read on - if not let me know.

It can be done with a simple insert statement - such as:

Code:
INSERT INTO MainTable (TeamLeaderID,Crew,Date,WhateverElse)
SELECT [Forms]![YourForm]![txtNewTeamLeader] as NewTeamLeader, Crew, Date, WhateverElse
FROM MainTable;
HTH

Steven

There are 10 kinds of people in the world - those who understand binary - and those with friends
 
Old July 23rd, 2003, 07:58 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Steven,

Case of beer coming down your way to Melbourne....

Thank you very, very much ! The solution was a lot simpler and it works ! This thing had me thinking for 2 days and the code i came up with so far was like War and Peace compared to yours.



Vladimir
Australia





Similar Threads
Thread Thread Starter Forum Replies Last Post
Append Query bright_mulenga Access 1 January 3rd, 2007 01:33 PM
Append Query Cybersurfer Access 1 February 13th, 2006 01:02 PM
append query? bph Access 2 November 23rd, 2004 12:44 PM
Subform Append Query powerpointpete Access 1 December 11th, 2003 07:05 PM
append query stoneman Access 2 November 12th, 2003 09:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.