Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 5th, 2007, 04:56 AM
Friend of Wrox
 
Join Date: Apr 2007
Location: , , .
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



Reply With Quote
  #2 (permalink)  
Old June 5th, 2007, 05:30 AM
Friend of Wrox
 
Join Date: Apr 2006
Location: Ternat, , Belgium.
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...

Reply With Quote
  #3 (permalink)  
Old June 5th, 2007, 06:38 AM
Friend of Wrox
 
Join Date: Apr 2007
Location: , , .
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



Reply With Quote
  #4 (permalink)  
Old June 5th, 2007, 10:24 AM
Friend of Wrox
 
Join Date: Apr 2007
Location: , , .
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

Reply With Quote
  #5 (permalink)  
Old June 5th, 2007, 10:56 AM
Friend of Wrox
 
Join Date: Apr 2007
Location: , , .
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


Reply With Quote
Reply


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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 05:36 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.