Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access 2007 query into textbox

Posted on 2009-03-31
6
Medium Priority
?
760 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 400 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
Industry Leaders: 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!

 
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 1600 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
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 …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 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