Placein the value of a combo Box column into a text box

B

Betsy

This should be easy! Here is the code...

Private Sub Combo18_AfterUpdate()

Me![SchoolID] = Me!Combo18.Column(1)
Me![Counselor Name] = Me!Combo18.Column(2)

End Sub

The problem is that it will not accept the first line:

Me![SchoolID] = Me!Combo18.Column(1)

If I move it around it is perfectly willing to place the counselor's name
into the correct text box, but for the schoolID it says I have to save the
record first. Anyone have any idea why???

I've checked and rechecked spelling, properties, etc!

Thanks for any help you can give.
 
J

John W. Vinson

This should be easy! Here is the code...

Private Sub Combo18_AfterUpdate()

Me![SchoolID] = Me!Combo18.Column(1)
Me![Counselor Name] = Me!Combo18.Column(2)

End Sub

The problem is that it will not accept the first line:

Me![SchoolID] = Me!Combo18.Column(1)

If I move it around it is perfectly willing to place the counselor's name
into the correct text box, but for the schoolID it says I have to save the
record first. Anyone have any idea why???

I've checked and rechecked spelling, properties, etc!

Thanks for any help you can give.

Is SchoolID an Autonumber field? What's the Bound Column and Control Source of
Combo18? What's the Recordsource of the form?

I worry that you may be storing information redundantly: why is it necessary
to store both these fields? Could the Counselor Name be looked up using a
query instead?

John W. Vinson [MVP]
 
B

Betsy

I don't need to save the counselor name and it can be looked up using a
query. the user wants to be able to see it. I guess she could see it on the
report rather than the form.

She needs to be able to choose a school and enter some information about the
school. she has given me an excel spreadsheet she's been using and wants her
interface to look as alike the spreadsheet as possible.

The value I need to store in the table is the SchoolID. Since wirting this
I think I've conquered that problem. Just needed to step away and rethink
what I was doing. but I still don't understand why the code wasn't working.
School ID was not an auto-number in this case. It was pulled from a query
using a field linked to the School table. It was, however, the bound column.
Would that have something to do with it? Just trying to learn at this point.

thanks for your help.


John W. Vinson said:
This should be easy! Here is the code...

Private Sub Combo18_AfterUpdate()

Me![SchoolID] = Me!Combo18.Column(1)
Me![Counselor Name] = Me!Combo18.Column(2)

End Sub

The problem is that it will not accept the first line:

Me![SchoolID] = Me!Combo18.Column(1)

If I move it around it is perfectly willing to place the counselor's name
into the correct text box, but for the schoolID it says I have to save the
record first. Anyone have any idea why???

I've checked and rechecked spelling, properties, etc!

Thanks for any help you can give.

Is SchoolID an Autonumber field? What's the Bound Column and Control Source of
Combo18? What's the Recordsource of the form?

I worry that you may be storing information redundantly: why is it necessary
to store both these fields? Could the Counselor Name be looked up using a
query instead?

John W. Vinson [MVP]
 
R

Ron2006

Yes





- Show quoted text -

Well, that shot that approach. I was thinking that maybe the combobox
was bound to the school ID therefore trying to move the combobox value
to the field it was already bound to would give you a conflict.


hmmmm
 
B

Betsy

Thanks. I don't know what I did wrong, but I did it another way at this
point it is working. Just a Conundrum and I thought someone else would see
what I'm not seeing.

Thanks,
 
Top