Solved

Use listbox selection to populate editable fields in subform

Posted on 2008-10-16
4
461 Views
Last Modified: 2013-11-28
Title: Use listbox selection to populate editable fields in subform

Greetings experts. I really appreciate your efforts. I have thoroughly researched this method before writing and now need your advice.
I can't get the solutions suggested in the various questions on the topic to work.

Table:       Inventory
Index:       ProductId
Form:       SearchEntries
Textbox:      txtCriteria      (after update, populate listbox "ListInventory")
Listbox:       ListInventory
ListInventory.Column(0): ProductId field

Goal: <DoubleClick> the "ListInventory" listbox to populate subform: "UpdateInventoryItem".

I have included the following code to accomplish this action:

Private Sub ListInventory_DblClick(Cancel As Integer)

DoCmd.OpenForm "UpdateInventoryItem", , , "ProductID = " & Me.ListInventory.Column(0)DoCmd.OpenForm "UpdateInventoryItem", , , "ProductID = " & Me.ListInventory.Column(0)      'This line opens form "UpdateInventoryItem" (temporary fix)

Me.UpdateInventoryItem.Form.Filter = "[ProductId]='" & Me.ListInventory.Column(0) & "'"
Me.UpdateInventoryItem.Form.FilterOn = True

End Sub

I get the error message: Method 'Form' of object '_SubForm' failed

Additional Info:

Properties Window
subUpdateInventoryItem
      Source Object:             UpdateInventoryItem
      Link Child Fields:       ProductId
      Link Master Fields:       ProductId


What am I missing?  


TEST---AJ-Adams-Specialty-Sales-.mdb
0
Comment
Question by:ajadams1
  • 3
4 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 250 total points
ID: 22731798
I can't open your database, but...

1. If your ID field is numeric, drop the single quotes from your filter:

Me.UpdateInventoryItem.Form.Filter = "[ProductId]=" & Me.ListInventory.Column(0)


2. Since you have the Master/Child links set to productID, setting the filter on the main form should suffice:

Me.Filter = "[ProductId] =" & Me.ListInventory.Column(0)
Me.FilterOn = True
0
 
LVL 61

Expert Comment

by:mbizup
ID: 22731939
Finally (If you need to refer to your subform, rather than applying the filter to the main form):

3.  From the properties that you posted, it looks like your subform control (the control that "houses" your subform) is actually named subUpdateInventoryItem.  This is the name that you need to use in your code (it may differ from the name of the subform as you see it in the database window):

>  Me.UpdateInventoryItem.Form.Filter

should be:

Me.subUpdateInventoryItem.Form.Filter

same thing for the FilterOn code...
0
 

Author Closing Comment

by:ajadams1
ID: 31506747
Thanks, mbizup!

I just wonder why you couldn't open the database. It shouldn't have had any security or protection (or is it because you don't have Access installed).

Regards,

Andrew
0
 
LVL 61

Expert Comment

by:mbizup
ID: 22737602
Hi,

<I just wonder why you couldn't open the database.>

Sorry - I should have been more specific. Some of my volunteer time here is during down-times at work. I can't download and open databases from my work computer.



0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question