Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Use listbox selection to populate editable fields in subform

Posted on 2008-10-16
4
Medium Priority
?
482 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 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

916 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