Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 November 4th, 2003, 08:26 AM
Authorized User
 
Join Date: Nov 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default form / listbox question

I have a table that stores mailing list contacts. I have a listbox that lists all the last names in the table (from a query).

1- I would like to be able to double click on a name in the listbox and open that record in my contact form to be edited. Everytime I double click on a name, the form, opens but on the first record; not on the name selected.

2- Instead of just the last name populating in the listbox, I would like the format (last, first).

I know these are probably very simple issues but I'm not having any luck trying to solve them. If anyone can point me in the right direction, I would greatly appreciate it.

Thanks,
Nick

 
Old November 4th, 2003, 09:12 AM
Authorized User
 
Join Date: Jun 2003
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

1 - You can run a query to select the record you want to edit but using defining criteria like: SELECT * FROM Table1 WHERE Field1='defining criteria';
Your defining criteria can be your primary key or something that will set the record in question apart.

2 - The query that makes the list needs to look like this: SELECT Table1.Last & ', ' & Table1.First AS Name FROM Table1;

Hope this helps.

Kenny Alligood
 
Old November 4th, 2003, 09:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

1) On the listbox's Double Click event put something like:
Code:
   DoCmd.OpenForm "frmMyForm", , , "criteria expression here"
where the criteria expression is any valid criteria, e.g. "[Name] = '" & Me.txtName & "'"

2) In the listbox's properties, set the Column Count property to 2, set the Column widths to e.g. 2";2" (two inches each), set the list width to the sum of the columns (in this case 4"), and set the Bound Column to 1 or 2 depending on which field you want to use in your calculations/operations.

On your listbox's recordsource property, make sure you're selecting the two fields in question. They'll both show up on your list but only the bound one will affect anything.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
updating listbox content from a sub form maricar C# 14 August 12th, 2008 11:55 PM
Altering a listbox from another form Firestorm9 C# 2005 1 July 9th, 2007 06:12 AM
simple listbox question joviyach VB.NET 2002/2003 Basics 1 October 2nd, 2006 07:59 AM
How to Update a Listbox on Different Form boxwalah C# 2 February 24th, 2006 12:22 PM
Listbox selection in a form jpcoutts Access 1 November 10th, 2004 05:02 PM





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