Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Your site was well structured and I found what I was looking for in about 2 minutes. I am looking forward to participating with you in the future..."

Geography

Where in the world do Tek-Tips members come from?

populating text boxes from change to a Combo boxHelpful Member! 

robojeff (TechnicalUser)
5 Jul 12 10:03
I have a form (MAC_addr_frm) with a combo box (DVcode)
which is populated by the table Device_Code_tbl.ID

I am trying to populate the following 3  text boxes on this form
from what device code is selected by the DVcode combo box:

1). pNum - to be populated from Device_Code_tbl.Asm_Num

2). Descr - to be populated from Device_Code_tbl.Descr

3). Laddr - to be populated from MAC_Addr_tbl.Lastaddr


So I created the following query (Mac_addr_qry):

SELECT Device_Code_tbl.Asm_Num, MAC_Addr_tbl.Lastaddr, Device_Code_tbl.Descr
FROM Device_Code_tbl INNER JOIN MAC_Addr_tbl ON Device_Code_tbl.ID = MAC_Addr_tbl.ID
WHERE (((Device_Code_tbl.ID)=[forms]![MAC_addr_frm]![DVcode]));

Then in an attempt to populate the 3 text boxes, I set the control source
for these to the following:

pnum =[Mac_Addr_qry]![Asm_Num]

Descr  =[Mac_Addr_qry]![Descr]

Laddr =[Mac_Addr_qry]![Lastaddr]

In the OnChange event for the combo box DVcode, I put the following code:

Private Sub DVcode_Change()
DoCmd.OpenQuery "Mac_Addr_qry", acViewNormal, acReadOnly
Repaint
End Sub

So when I change the value in the DVcode combo box, the 3 text boxes
do not get updated and the Mac_Addr_qry results pop up...

What am I doing wrong and how can I correct this so that the  text boxes
get updated and the query results does not pop up...

thanks
PHV (MIS)
5 Jul 12 12:44
Use this RowSource for the combo DVcode:
SELECT D.ID,D.Asm_Num,M.Lastaddr,D.Descr FROM Device_Code_tbl D INNER JOIN MAC_Addr_tbl M ON D.ID=M.ID ORDER BY 1

And then the ControlSources,
for pnum:
=[DVcode].Column(1)
for Descr:
=[DVcode].Column(3)
for Laddr:
=[DVcode].Column(2)

Hope This Helps, PH.
FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

robojeff (TechnicalUser)
5 Jul 12 14:12

Works Great PHV

Thanks again for your help!
robojeff (TechnicalUser)
5 Jul 12 15:40


My first reply was a quick thank you but as I looked at this, I wish to understand it better so that I can learn how to use it elsewhere.

This does work really good and hope you don't mind a couple follow up questions so that I can understand it a little bit better...

You suggested:
SELECT D.ID,D.Asm_Num,M.Lastaddr,D.Descr FROM Device_Code_tbl D INNER JOIN MAC_Addr_tbl M ON D.ID=M.ID ORDER BY 1

1. In this Select statement, you use D.ID & D.Asm_Num; is D. an actual table that you are creating or an alias, or why do you use this instead of just using Device_Code_tbl.Asm_Num?

2. I am guessing that if Lastaddr was in Device_Code_tbl instead of MAC_Addr_tbl then there would be no need for the INNER JOIN, but if this was the case how would the Select statement appear?

3. What does the [DVcode].Column(?) relate to and how are these indexed to the control?

Thanks again!
Helpful Member!  PHV (MIS)
5 Jul 12 17:28
1. an alias
2. I don't know your DB scema
3. With the new RowSource the combobox has 4 columns

Hope This Helps, PH.
FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close