Connecting Tech Pros Worldwide Help | Site Map

Update a combobox

jim
Guest
 
Posts: n/a
#1: Nov 13 '05
Hi NG

I have a form in which I use a combobox - the content of the combobox depend
on the customername shown in a textbox.

Now my problem is that I want the content in the combobox to change every
time a record with a new customername is chosen.

I have tried to put in a me.controls("combobox").requery in afterupdate
event, and also a lot of other events, but it does not work.

Any surgestions?

Thx in advance
JJ


Phil Stanton
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Update a combobox


OnCurrent of Form
(Assuming the combo box is used to find a customer record on the form)
Me!ComboBox = Me!CustomerID
or more simply
ComboBox = CustomerID
HTH

Phil


"jim" <jim@get2net.dk> wrote in message
news:41e164be$0$141$edfadb0f@dread11.news.tele.dk. ..[color=blue]
> Hi NG
>
> I have a form in which I use a combobox - the content of the combobox
> depend
> on the customername shown in a textbox.
>
> Now my problem is that I want the content in the combobox to change every
> time a record with a new customername is chosen.
>
> I have tried to put in a me.controls("combobox").requery in afterupdate
> event, and also a lot of other events, but it does not work.
>
> Any surgestions?
>
> Thx in advance
> JJ
>
>[/color]


jim
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Update a combobox


Hi Phil

Thx for your answer - it works, but at the same time it comes up with a
warning - saying something like : "Microsoft Access can't find the macro
"Me!Kontaktperson = Me!Kundenavn" where Kontaktperson is the name of the
combobox, and kundenavn the name of the textbox which the combobox is
filtered after

"Phil Stanton" <discussion@stantonfamily.co.uk> skrev i en meddelelse
news:41e19829$0$108$65c69314@mercury.nildram.net.. .[color=blue]
> OnCurrent of Form
> (Assuming the combo box is used to find a customer record on the form)
> Me!ComboBox = Me!CustomerID
> or more simply
> ComboBox = CustomerID
> HTH
>
> Phil
>
>
> "jim" <jim@get2net.dk> wrote in message
> news:41e164be$0$141$edfadb0f@dread11.news.tele.dk. ..[color=green]
> > Hi NG
> >
> > I have a form in which I use a combobox - the content of the combobox
> > depend
> > on the customername shown in a textbox.
> >
> > Now my problem is that I want the content in the combobox to change[/color][/color]
every[color=blue][color=green]
> > time a record with a new customername is chosen.
> >
> > I have tried to put in a me.controls("combobox").requery in afterupdate
> > event, and also a lot of other events, but it does not work.
> >
> > Any surgestions?
> >
> > Thx in advance
> > JJ
> >
> >[/color]
>
>[/color]


Phil Stanton
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Update a combobox


Hi Jim

I am assuming you have a form of contacts and a field holding all sorts of
information including the Key of the Contact Table:- ContactID,
ContactName, Address, Phone etc

The SQL for the combo box should look something like
SELECT ContactPerson, ContactID FROM Contacts ORDER BY ContactPerson;
The combo box would have 2 columns, width say 3cms; 0cms and the bound
column Column2.
It is an UNBound Combo box

So the AfterUpdate of the ComboBox will say
Private Sub Kontaktperson_AfterUpdate

DoCmd.GotoControl "ContactID"
DoCmd.FindRecord Kontaktperson

End Sub
After selecting the contact from the box you will get to the correct
record.
On the other hand, if you run through the records using the next button on
the bottom of the form, by using the code I sent the other day, you will
highlight the name in the Combo Box.

This now changes to

Private Sub Form_Current()

Kontaktperson = CustomerID

End Sub

The On
"jim" <jim@get2net.dk> wrote in message
news:41e44433$0$200$edfadb0f@dread11.news.tele.dk. ..[color=blue]
> Hi Phil
>
> Thx for your answer - it works, but at the same time it comes up with a
> warning - saying something like : "Microsoft Access can't find the macro
> "Me!Kontaktperson = Me!Kundenavn" where Kontaktperson is the name of the
> combobox, and kundenavn the name of the textbox which the combobox is
> filtered after
>
> "Phil Stanton" <discussion@stantonfamily.co.uk> skrev i en meddelelse
> news:41e19829$0$108$65c69314@mercury.nildram.net.. .[color=green]
>> OnCurrent of Form
>> (Assuming the combo box is used to find a customer record on the form)
>> Me!ComboBox = Me!CustomerID
>> or more simply
>> ComboBox = CustomerID
>> HTH
>>
>> Phil
>>
>>
>> "jim" <jim@get2net.dk> wrote in message
>> news:41e164be$0$141$edfadb0f@dread11.news.tele.dk. ..[color=darkred]
>> > Hi NG
>> >
>> > I have a form in which I use a combobox - the content of the combobox
>> > depend
>> > on the customername shown in a textbox.
>> >
>> > Now my problem is that I want the content in the combobox to change[/color][/color]
> every[color=green][color=darkred]
>> > time a record with a new customername is chosen.
>> >
>> > I have tried to put in a me.controls("combobox").requery in afterupdate
>> > event, and also a lot of other events, but it does not work.
>> >
>> > Any surgestions?
>> >
>> > Thx in advance
>> > JJ
>> >
>> >[/color]
>>
>>[/color]
>
>[/color]


Closed Thread