Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 4th, 2003, 02:04 PM
Authorized User
 
Join Date: Aug 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default refer to list box on another form

I have a list box with 3 columns, 1 bound and 2 displayed. What I want to do is select an item in the list box, then open another form and then have a text box display the 2 displayed fields from the previous form. I have the text box on the new form referring back to the list box, but the value that is showing is the bound value, which doesn't have any meaning. Any suggestions?

Thanks,
-Tim


 
Old August 4th, 2003, 11:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi Tim,

If you open the second form from the first form (say by double-clicking the listbox) you can:

1. base the second form on a query that concatenates the two fields displayed in the listbox, and

2. filter the second form by the bound field from the listbox.

Here's what I mean:

Say your list box lists three fields: CustomerID, CustFirstName, CustLastName. CustomerID is bound. You want the textbox on form two to display the customers full name, i.e., [CustFirstName] & " " & [CustLastName].

First, use the following query as form two's record source:

SELECT
  tblCustomers.CustomerID,
  [CustFirstName] & " " & [CustLastName] AS CustomerFullName
FROM
  tblCustomers;

Bind your textbox on form two to the aliased field in the query (CustomerFullName).

Second, place this code in the listbox's double-click event behind form one:

Private Sub List1_DblClick(Cancel As Integer)

    DoCmd.OpenForm "frmCustomer", , , "CustomerID = " & Me![List1]

End Sub

The where condition synchronizes the two forms, and the concatenated field populates your textbox.

HTH,

Bob
 
Old August 5th, 2003, 07:05 AM
Authorized User
 
Join Date: Aug 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Bob..

Thanks a lot!! That worked very well.

-Tim







Similar Threads
Thread Thread Starter Forum Replies Last Post
Subject: use the Form property to refer to a form ayazhoda Access VBA 5 May 19th, 2008 04:39 AM
copy a list box from a form to a report bjcountry Access 1 April 18th, 2008 03:14 PM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
Retain form value from dependent list box qhong Dreamweaver (all versions) 18 November 4th, 2004 03:36 AM
Drop Down/Combo box/List in a Form from DB mazimi Classic ASP Basics 2 October 1st, 2004 10:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.