Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Use listbox selection to populate editable fields in subform

Posted on 2008-10-16
4
Medium Priority
?
478 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
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.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

670 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