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
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 Display Modes
  #1 (permalink)  
Old May 29th, 2006, 04:32 PM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using a variable to define a column name

Hi,

If anyone can assist, it would be much appreciated. I am writing a search form that currently has 3 combo boxes. What I am trying to do is use the value of one of the controls as a variable to SELECT a column in a query. I can't seem to make it work. I know that I can pass control information as query criteria, but can I use a variable in a select statement? Is there anyway to use the value from my combo box to retrieve the column with that name?

Thanks,

Tara
Reply With Quote
  #2 (permalink)  
Old May 30th, 2006, 06:34 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Yes.

You can make a list of column names that are meaningful to the user by populating the list yourself, or you can use the actual column names using a look up on the table you are querying.

Will you use the primary key to look up the records, or some text value?

How are you using the column? It sounds like you are allowing the user to look for a value in their choice of columns. If that is the case, then your link criteria might look like:

sColumnValue = Me.cboColumn
sOtherValue = Me.cboOtherValue

sLink = "[" & sColumnValue & "] = " & "'" & sOtherValue & "'"

That is how you would do this with a text value. If you were using a numeric value, you would use:

sLink = "[" & sColumnValue & "] = " & sOtherValue

Does this help?



mmcdonal
Reply With Quote
Reply


Thread Tools
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
Input javascript variable into hyperlink column toddw607 ASP.NET 2.0 Basics 1 April 17th, 2008 10:12 AM
How to define .tld wesleygch JSP Basics 1 April 10th, 2007 07:54 AM
How to replace db column name with Global variable nesrine C# 0 March 5th, 2007 09:06 AM
Can u define difference ? gvcc_neel .NET Framework 2.0 4 October 10th, 2005 04:56 AM
find name and define range for Column qball Excel VBA 4 November 17th, 2004 02:55 PM



All times are GMT -4. The time now is 12:44 AM.


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