Solved

Use listbox selection to populate editable fields in subform

Posted on 2008-10-16
4
459 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
count unique records in access report 2 23
Library not Registered 16 50
Acc 2010 pause execution 10 9
Setting a DEFAULT value within a linked table 4 10
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

896 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now