Solved

Access 2007 query into textbox

Posted on 2009-03-31
6
751 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
  • 2
  • 2
  • 2
6 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
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 119

Accepted Solution

by:
Rey Obrero earned 400 total points
Comment Utility
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
Comment Utility
Thanks Guys!  Appreciate the quick response.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now