Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 4th, 2003, 02:04 PM
Authorized User
 
Join Date: Aug 2003
Location: Pittsburgh, PA, USA.
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


Reply With Quote
  #2 (permalink)  
Old August 4th, 2003, 11:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
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
Reply With Quote
  #3 (permalink)  
Old August 5th, 2003, 07:05 AM
Authorized User
 
Join Date: Aug 2003
Location: Pittsburgh, PA, USA.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Bob..

Thanks a lot!! That worked very well.

-Tim


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:15 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.