Solved

Access 2007 query into textbox

Posted on 2009-03-31
6
756 Views
Last Modified: 2013-11-28
I'm new to Access so i hope this question isn't too basic.
This is basically a modification to the "sales pipeline" database (comes with Access 2007) since it had similarities to what i wanted to write.  I have an access table called "Employees" where there is a field called "comission_rate", which allows me to log each employees commission rate.
I have a second table called "keystoneopportunities" (to log sales opportunity data) where there is a field called "sales1", which documents who the primary salesman is.
On the form "OpportunityInput", which is the input form for a sales opportunity, i have a combobox for the purpose of selecting a salesman.  The control source is "sales1" mentioned earlier.  The rowsource is:

SELECT [Employees Extended].ID, [Employees Extended].[Employee Name] FROM [Employees Extended] ORDER BY [Employees Extended].[Employee Name];

this sets the items i see in the combobox dropdown.

Adjacent to the above combobox where i can select an employee, i would like to have their commission rate (which will be used in some calculations later).  I'm assuming i would place a textbox for this result to be displayed.  Can anyone help me with how to get commission rate to query into this text box?  Also, if the commission rate/% is displayed in a textbox, will it be treated as a number (and not text) so that i can use it in calculations?
0
Comment
Question by:GTC-KTX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24032589
you can use the following in the afterupdate event of the combo

private sub comboName_afterupdate()

me.text1=cdbl(dlookup("comission_rate","Employees","[ID]= " & me.comboName))

end sub
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 100 total points
ID: 24032598
Add the Commission rate to the combobox row source:

SELECT [Employees Extended].ID, [Employees Extended].[Employee Name],  [Employees Extended].[EmployeeCommissionRate]
FROM [Employees Extended] ORDER BY [Employees Extended].[Employee Name];


Then drop a textbox on the form and set the control source to:

    =YourComboBox.Column(2)

JeffCoachman
0
 

Author Comment

by:GTC-KTX
ID: 24032916
Thanks for both replies.  i didn't really want the commision rates to show up in the combobox, so i tried to implement the first solution (from Capricorn1).  This seems to work fine except when an employee is chosen that doesn't have a commission value in the table.  I get Run-time error  '94' (Invalid use of null).
Any suggestions?
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24033176
GTC-KTX,

These are two techniques to do the same thing.

If you set the Column widths property of the combobox, you can hide any column you like.

Jeff
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 400 total points
ID: 24033186
try this

private sub comboName_afterupdate()

me.text1=cdbl(nz(dlookup("comission_rate","Employees","[ID]= " & me.comboName),0)

end sub
0
 

Author Closing Comment

by:GTC-KTX
ID: 31565011
Thanks Guys!  Appreciate the quick response.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question