Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 10th, 2009, 04:16 AM
Richjjk Richjjk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2009
Posts: 6 Richjjk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 27 m 43 sec
Reputation Power: 0
Forms - Moving data between subforms

I have recently started to develop a database using Access 2003 to handle the purchase of materials for a business.

One of my main forms, called frmMaterials, deals with every aspect of placing an order with a supplier. It contains 4 tabs each with a different section of the order process.

The first tab concerns placing an order from a pre-generated list of required materials. This tab contains three subforms based on different queries and in a table view.

Subform 1, named subRequired, lists all the required materials for that particular user.

Subform 2, named subMaterials, lists all the materials that exist in the database and is filtered by category which is selected in a combobox nearby.

Subform 3, named subBasket, is a basket where all items selected as part of this order will reside until a user confirms the order using a button.

What I am struggling with is trying to get items selected in subform 2 to have their details copied to subform 3 when an "order" button is pressed (or the record in subform 2 is double clicked).

I have looked through a number of articles on the forums and found some snippets of code which could possibly be related to my issue but so far I havent been able to get them to work in my particular circumstance.

Any help would be much appreciated.

Cheers,

Rich

Reply With Quote
  #2  
Old November 10th, 2009, 08:48 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 1,113 June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 23 h 1 m 46 sec
Reputation Power: 240
What do you mean by 'copied'. You should not be saving the same data in multiple tables. If what you need to do is display updates to form and subform queries then use the Requery method. If these form/subforms can have master/child links, the Requery may not be needed.

Reply With Quote
  #3  
Old November 11th, 2009, 06:43 AM
Richjjk Richjjk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2009
Posts: 6 Richjjk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 27 m 43 sec
Reputation Power: 0
Quote:
Originally Posted by June7
What do you mean by 'copied'. You should not be saving the same data in multiple tables.

Ah yes i see what you mean, I dont want to be copying all the data to another table at all. I should know better really. So what I would need in the table behind subform 3 would be only the Material ID (which would be able to give me all the information from the materials table without replication of data), Quantity Ordered and a Date ordered.

So what i need to be able to do is select a record in subform 2 and have the current record's Material ID placed in a new record in subform3 when a button is pressed. The user could then manually fill in quantity required.

Looking through the tutorial videos in the stickies I have found that i can reference the subforms using:

Me.subMaterials.Form!MaterialID

So maybe i could make some code for a button something like:

Code:
Private Sub cmdOrder_click()

Variable = Me.subMaterials.Form!MaterialID

INSERT INTO tblBasket (MaterialID)
VALUES (Variable)
End Sub

I will experiment a bit more and see what i come up with.

Reply With Quote
  #4  
Old December 3rd, 2009, 07:59 AM
Richjjk Richjjk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2009
Posts: 6 Richjjk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 27 m 43 sec
Reputation Power: 0
I have been working off and on with this part of my database and have managed to come up with the following VB and SQL. This code is attached to a button's on click event for the moment.

Code:
DoCmd.RunSQL "INSERT INTO tblBasket (CategoryName, Description) SELECT CategoryName, Description FROM tblMaterial WHERE MaterialID = Me.subOrder.Form!MaterialID"


For some reason however it is asking me to manually provide values for the CategoryName and Description in the SELECT part of the SQL.

I tried to replicate the code present on the MSDN page for Insert Into. Am I missing something obvious?

Reply With Quote
  #5  
Old December 4th, 2009, 03:53 AM
marissa jasmine marissa jasmine is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2009
Posts: 37 marissa jasmine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 59 sec
Reputation Power: 1
You can view or enter data in a main form and in a subform by switching back and forth between them to move through their records or to add new records.....


Thanks and hope it's can useful

Reply With Quote
  #6  
Old December 11th, 2009, 06:46 AM
Richjjk Richjjk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2009
Posts: 6 Richjjk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 27 m 43 sec
Reputation Power: 0
I tried modifying the SQL a bit to:

Code:
DoCmd.RunSQL "INSERT INTO tblBasket (Description, BasketID) 
VALUES (" & Me.subOrder.Form!Description & ", 0001)"


It produces the following error:

Run-time error '3075'

Syntax error (missing operator) in query expression 'SPEED ADHESIVE'.

SPEED ADHESIVE is the Description of the product i had selected in the subform so it is correctly grabbing this info.

any hints?

Reply With Quote
  #7  
Old December 11th, 2009, 05:17 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 1,113 June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 23 h 1 m 46 sec
Reputation Power: 240
Use apostrophe delimiter for string values:

DoCmd.RunSQL "INSERT INTO tblBasket (Description, BasketID)
VALUES ('" & Me.subOrder.Form!Description & "', '0001')"

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Forms - Moving data between subforms


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 11 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek