A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Help-How to retreive multiple records from 1 subform to another subform?



 
 
Thread Tools Display Modes
  #1  
Old July 26th, 2006, 09:30 PM posted to microsoft.public.access.forms
Ramona
external usenet poster
 
Posts: 9
Default Help-How to retreive multiple records from 1 subform to another subform?

Hi there,
Im wondering if anybody could help me on this. I have 1 subform
(EditTarget) and 2 nested subforms (EditOrderDetails and
EditProductSubform)within 1 Main Form (EditCustomer). In EditTarget
subform, I have records of "ProductName" along with its
"TargetCapacity" that is associated with each Customers (1-M
relationship). What I would like to do is to somehow retrieve the
"ProductName" records linked to customers into a textbox called
"ProductID" in EditProductSubform. Thus, when I open the EditCustomer
Main Form, it will automatically fill the "ProductID" textbox with
multiple records in Detail sections of EditProductSubform.
I tried to do it by using Dlookup but it only gives me the first value.

I guess, thats because Dlookup will only return single value. Thus, I m

trying to use Recordset. However, my code currently is not working.
Here is what I got so far:

Private Sub Form_Activate()
Me.ProductID = [ProductName]
Dim db As DAO.Database, rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.openrecordset("SELECT [ProductName] FROM
tblTargetCapacity WHERE [Customers ID]=" &
[Forms]![EditCustomers]![EditOrderDetails].[Form]![EditProductSubform].[For*m].[CustID])

With rs
While Not .EOF
Debug.Print ![ProductName]
.MoveNext
Wend
End With


End Sub


I dont know how to show that "ProductName"( in the line
"Debug.Print![ProductName]" ) in the EditProductSubform.
Any help or suggestions will be greatly appreciated because Im so lost
in this!!


Thanks!


Reply »

  #2  
Old July 27th, 2006, 05:12 AM posted to microsoft.public.access.forms
John Vinson
external usenet poster
 
Posts: 4,033
Default Help-How to retreive multiple records from 1 subform to another subform?

On 26 Jul 2006 13:30:03 -0700, "Ramona"
wrote:

Hi there,
Im wondering if anybody could help me on this. I have 1 subform
(EditTarget) and 2 nested subforms (EditOrderDetails and
EditProductSubform)within 1 Main Form (EditCustomer). In EditTarget
subform, I have records of "ProductName" along with its
"TargetCapacity" that is associated with each Customers (1-M
relationship). What I would like to do is to somehow retrieve the
"ProductName" records linked to customers into a textbox called
"ProductID" in EditProductSubform. Thus, when I open the EditCustomer
Main Form, it will automatically fill the "ProductID" textbox with
multiple records in Detail sections of EditProductSubform.
I tried to do it by using Dlookup but it only gives me the first value.

I guess, thats because Dlookup will only return single value. Thus, I m
trying to use Recordset. However, my code currently is not working.


Your basic error is assuming that data is stored in Subforms or in
Textboxes. It isn't. It's stored in tables; the form is only a window,
a tool to let you view data.

If - and I REALLY have to question the validty of this entire
operation!!! - you want to copy multiple detail records, an Append
query into the table upon which the Product Subform is based would be
the appropriate technique.

John W. Vinson[MVP]
  #3  
Old July 27th, 2006, 06:18 PM posted to microsoft.public.access.forms
Ramona
external usenet poster
 
Posts: 9
Default Help-How to retreive multiple records from 1 subform to another subform?

Hi John,
Thanks for replying! After I worked it out for quite some time, I
managed to do it. Your suggestion actually helped me.

Thanks!
Ramona

John Vinson wrote:
On 26 Jul 2006 13:30:03 -0700, "Ramona"
wrote:

Hi there,
Im wondering if anybody could help me on this. I have 1 subform
(EditTarget) and 2 nested subforms (EditOrderDetails and
EditProductSubform)within 1 Main Form (EditCustomer). In EditTarget
subform, I have records of "ProductName" along with its
"TargetCapacity" that is associated with each Customers (1-M
relationship). What I would like to do is to somehow retrieve the
"ProductName" records linked to customers into a textbox called
"ProductID" in EditProductSubform. Thus, when I open the EditCustomer
Main Form, it will automatically fill the "ProductID" textbox with
multiple records in Detail sections of EditProductSubform.
I tried to do it by using Dlookup but it only gives me the first value.

I guess, thats because Dlookup will only return single value. Thus, I m
trying to use Recordset. However, my code currently is not working.


Your basic error is assuming that data is stored in Subforms or in
Textboxes. It isn't. It's stored in tables; the form is only a window,
a tool to let you view data.

If - and I REALLY have to question the validty of this entire
operation!!! - you want to copy multiple detail records, an Append
query into the table upon which the Product Subform is based would be
the appropriate technique.

John W. Vinson[MVP]


  #4  
Old July 27th, 2006, 07:11 PM posted to microsoft.public.access.forms
Ramona
external usenet poster
 
Posts: 9
Default Help-How to retreive multiple records from 1 subform to another subform?

Hi John,
Thanks for replying! After I worked it out for quite some time, I
managed to do it. Your suggestion about the Append Query actually
helped me.

Thanks!
Ramona

John Vinson wrote:
On 26 Jul 2006 13:30:03 -0700, "Ramona"
wrote:

Hi there,
Im wondering if anybody could help me on this. I have 1 subform
(EditTarget) and 2 nested subforms (EditOrderDetails and
EditProductSubform)within 1 Main Form (EditCustomer). In EditTarget
subform, I have records of "ProductName" along with its
"TargetCapacity" that is associated with each Customers (1-M
relationship). What I would like to do is to somehow retrieve the
"ProductName" records linked to customers into a textbox called
"ProductID" in EditProductSubform. Thus, when I open the EditCustomer
Main Form, it will automatically fill the "ProductID" textbox with
multiple records in Detail sections of EditProductSubform.
I tried to do it by using Dlookup but it only gives me the first value.

I guess, thats because Dlookup will only return single value. Thus, I m
trying to use Recordset. However, my code currently is not working.


Your basic error is assuming that data is stored in Subforms or in
Textboxes. It isn't. It's stored in tables; the form is only a window,
a tool to let you view data.

If - and I REALLY have to question the validty of this entire
operation!!! - you want to copy multiple detail records, an Append
query into the table upon which the Product Subform is based would be
the appropriate technique.

John W. Vinson[MVP]


 




Thread Tools
Display Modes

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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:00 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.