Link to home
Start Free TrialLog in
Avatar of Kdankwah
KdankwahFlag for United States of America

asked on

Combo Box

What I am doing is to set the dept field as a Combobox or dropdown and when you pick a dept number the segment, dept desc and segdesc is autofilled.  Its not working and I don’t know what I am doing wrong?  See below for specs


AfterUpdate event

Private Sub cbodept_AfterUpdate()
Me.txtDepnmdesr = Me.cbodept.Column(3)
Me.txtSegm = Me.cbodept.Column(4)
Me.txtSegdescr = Me.cbodept.Column(5)
End Sub
===============================
Query sql in Row source of deot cbo

SELECT [Department and Segment table].ID, [Department and Segment table].Dept, [Department and Segment table].Segment, [Department and Segment table].Dept_Desc, [Department and Segment table].Segment_Desc
FROM [Department and Segment table];
=================================

Data of the query in the rowsource of the dept field combox

ID      Dept            Segment      Dept_Desc            Segment_Desc
1      0701101      07000001      General             Promise Programs
2      0701101      00000000      General            Undefined Segment


Thanks
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

In code, columns are numbered from 0 not from 1.

So your 5 columns are column(0) to column(4)
Avatar of Kdankwah

ASKER

Thanks, so it will be column 2,3,4.  I did change that but its still not working.  Should I use Onchange instead?
I changed the afterupdate to whats below, I am getting the "txtdepnmdesr" description to work OK but the other two are not.  Should I change the column to 2 and 3?  I will try that and see

Private Sub cbodept_AfterUpdate()
Me.txtDepnmdesr = Me.cbodept.Column(1)
Me.txtSegm = Me.cbodept.Column(3)
Me.txtSegdescr = Me.cbodept.Column(4)
End Sub

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes and its not working. I decided to set the segment and segment description too as combobox and get the user to do the same thing as the dept and description which is working,  When I do that, it works.  Does it make good database sense?

Thanks
what is the bound column of the original combo box  cboDept, is it set to 1 ?
I set it to 3.  When I set it to 1 it did not work
upload  a copy of the db
ok
can I get your email?
Here is the database.  Please check the relationship for me if its OK.

Thanks
experts-exchange.accdb
Your code is referring to textboxes using different names to the textboxes that are actually on ode the form. (in other words you've either used the wrong names in your code or you have forgotten to name the textboxes properly)
Thanks I got it to work now.