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 August 22nd, 2006, 09:16 AM
Registered User
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Question

Hello....I am also new to Access...and writing codes. I am currently creating a database where I have subforms. I want to have information flow from the main form to the subform for some fields. Then I want all of this information to flow to a table. So, I have created another table. This is the code I am using. It is not working, please help.

Private Sub Form_Load()

Dim db As DAO.Database
Set db = CurrentDb

CurrentDb.Execute = "INSERT INTO tblUpdateDate ( [Project ID], [Project Name], [Update Date] ) " & _
"SELECT s.[Project ID], s.[Project Name], s.[Update Date] " & _
"FROM tblAssessmentForm AS s WHERE (((s.[Project ID])=[Forms]![frmAssessmentForm]![Project ID]))"

DoCmd.RunSQL (sql)

 
Old August 22nd, 2006, 11:54 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You can do this, but you have to take the values as variables, then use the variables in your SQL statement. Put the entire SQL statement in its own variable, and then execute it.

Does this help?

mmcdonal
 
Old September 26th, 2006, 02:05 PM
pjm pjm is offline
Authorized User
 
Join Date: Jul 2006
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dim sql as string

sql = "INSERT INTO tblUpdateDate ( [Project ID], [Project Name], [Update Date] ) " & _
"SELECT s.[Project ID], s.[Project Name], s.[Update Date] " & _
"FROM tblAssessmentForm AS s WHERE (((s.[Project ID])=" & [Forms]![frmAssessmentForm]![Project ID] & "))"

DoCmd.RunSQL (sql)

BTW: Since most if not all submissions to a forum would be questions, it is not very helpful to make your subject "Question". I would suggest that the current topic should be something like "Querying Using a Subform". With all the messages that get posted to forums, I'm usually inclined to skip over those with an uninformative subject line.

-Phil-





Similar Threads
Thread Thread Starter Forum Replies Last Post
question maheshraju ASP.NET 2.0 Basics 3 March 13th, 2008 08:54 AM
Question Ashwini Classic ASP Databases 3 January 10th, 2006 07:20 AM
Question? Calibus Classic ASP Databases 8 August 6th, 2004 08:25 AM
a question gorji C++ Programming 2 August 11th, 2003 07:41 AM





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