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 June 5th, 2007, 04:56 AM
Friend of Wrox
 
Join Date: Apr 2007
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default Filling SubForm from ComboBox

Hi All,

Every day is about learning new thing in Access for me,
Yesterday i manage to fill one combobox from other now what i am trying to do is

Combobox 1 --> Fill with Supplier ID
Combobox 2 --> Fill with Product ID of relevant Supplier
Now on the bases of these two comboboxes I want to fill sub form which will shows all the result required

So far what i did i put sub form on main form and link with query
which is

SELECT Products.PID, Products.SID, Products.SupplierNum
FROM Products INNER JOIN ProductTypes ON products.ProductType=ProductTypes.ProductType
WHERE (((ProductTypes.SID)=Forms!ExportToExcel!cmbSuppli erList)) And (((ProductTypes.ProductType)=Forms!ExportToExcel!c mbProductTypes));

which is not populating subform and i tried this

SELECT Products.PID, Products.SID, Products.SupplierNum
FROM Products INNER JOIN ProductTypes ON products.ProductType=ProductTypes.ProductType
WHERE (((ProductTypes.SID)='AB')) And (((ProductTypes.ProductType)='18'));
which is working

Next Bit i have to do to finish this to export all sub form records in Excel sheet any magician programmer

I hope this is kind of question which will help every one joining this community

Regards

Ayaz



 
Old June 5th, 2007, 05:30 AM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What I think you should do is:

dim intSupplierID as integer 'cause I guess it's a number
dim intProductID as integer 'same as previous line

intSupplierID = me.combo1
intProductID = me.combo2

and then change your sql to:

SELECT Products.PID, Products.SID, Products.SupplierNum
FROM Products INNER JOIN ProductTypes ON products.ProductType=ProductTypes.ProductType
WHERE (((ProductTypes.SID)= " & intSupplierID & ")) And (((ProductTypes.ProductType)= " & intProductID & "));

This should do it...

 
Old June 5th, 2007, 06:38 AM
Friend of Wrox
 
Join Date: Apr 2007
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default

Hi Vince

Your help is excellent

but I am trying not to write SQL in VBA Coding will this work if I write it in query designer and call this query from record source of subform

Regards



 
Old June 5th, 2007, 10:24 AM
Friend of Wrox
 
Join Date: Apr 2007
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default

Hi

Private Sub cmbProductTypes_AfterUpdate()
Dim SupplierID
Dim ProductID
SupplierID = Me.cmbSupplierList
ProductID = Me.cmbProductTypes
ExportProductToExcel_subform.????????
End Sub

 
Old June 5th, 2007, 10:56 AM
Friend of Wrox
 
Join Date: Apr 2007
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default

Hi Vince... I've done that

Dim SupplierID
Dim ProductID
SupplierID = Me.cmbSupplierList
ProductID = Me.cmbProductTypes.Column(0)
Me.ExportProductToExcel_subform.Form.Recordsource = "SELECT Products.PID, Products.SID FROM Products INNER JOIN ProductTypes ON products.ProductType=ProductTypes.ProductType WHERE (((ProductTypes.SID)= '" & SupplierID & "')) And (((ProductTypes.ProductType)= " & ProductID & "))"


Thanks you







Similar Threads
Thread Thread Starter Forum Replies Last Post
filling the combobox using sql data adapter kumaran BOOK: Professional .NET 2.0 Generics 4 October 5th, 2015 07:57 AM
Filling ComboBox from Dataset dcathers C# 9 June 15th, 2013 03:31 AM
Filling a combobox/listbox unmeshraut VB How-To 1 September 21st, 2007 12:08 PM
Filling comboBox from an XML File kuznickic C# 2005 11 August 29th, 2007 01:54 AM
Filling Combobox with value from other Combobox ayazhoda Access VBA 6 June 5th, 2007 04:58 AM





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