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 VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 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 April 15th, 2005, 05:55 AM
Gus Gus is offline
Registered User
 
Join Date: Apr 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Coding help with data from a query

Hi guys,

Hope someone can help. It's been a little while since I programmed anything in VBA. Right now I have a DB project for anit-violence organisation that is presenting small problem to me. Here's my terribly short and messy pseudo code:

When cboClientName changes
   get the data from the field in the fourth column
   assign that data to txtClientID
end

Here's a break down. I have a query that gets a complete list of clients and their ID number. After I have choosen the name from the combo box, I want the ClientID vlaue to be shown in the text box txtClientID.

The query looks up First Name, Middle Name, Last Name, Client ID.

Thanks for any help,

Gus
Reply With Quote
  #2 (permalink)  
Old April 15th, 2005, 06:16 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Seattle, WA, .
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

What you want to accomplish can be done like this...

Me.txtClientID = Me.cboClientName.Column(3)

The index for Column starts at zero. To get the fourth column, use three.

However, I would highly recommend you do this...

Change the order of your query to put ClientID first.

In the properties of cboClientName:
Set the Bound Column to 1.
Set the Column Count to 4.
Set Column widths to 0";1";.5";1"
Set List Width to 2.75" (always set List Width to total of Columns widths plus 0.25" to allow for scroll bar)

Throw away the txtClientID field and just use cboClientName as the field that has the ID. You might want to rename cboClientName to cboClientID to keep things clear.

QED. No coding required.

This assumes that you don't really need the First Name of the client in cboClientName and that you don't need to show the users the ID number.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
Reply With Quote
  #3 (permalink)  
Old April 15th, 2005, 06:22 AM
Gus Gus is offline
Registered User
 
Join Date: Apr 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for that. I completely forgot about the Me thingy. Well that solves a lot of problems.

Gus
"It's the fuzz! Cheese it!" - Bender
Reply With Quote
  #4 (permalink)  
Old April 15th, 2005, 06:32 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Seattle, WA, .
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

BTW, depending on the client base, if you are changing the order of your fields, you might want to put Last Name second in your query so users can type the first few characters of the person's last name to jump to the area where the name is. Most people tend to think of these lookups by last name.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
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
How to Query Snapshot of Data in % feets SQL Server 2000 4 November 8th, 2007 04:41 AM
Help with efficient coding (part of Dynamic Query miamikk SQL Language 1 July 17th, 2007 05:32 AM
Hand Coding VS Data Wizards Bulldog BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 3 May 22nd, 2007 04:21 AM
Query data and exporting data from one sheet to an testman Excel VBA 2 April 28th, 2005 02:40 PM
Coding for data input from one form to 2 tables... dgarcia1128 Access VBA 1 February 19th, 2004 12:35 AM



All times are GMT -4. The time now is 02:56 AM.


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