Auto-choose combo box option

T

Terri

I have two combo boxes on a form. They are both based on the same table.

In certain instances, if certain choices are made on the first combo box,
I'd like to automatically update the second combo box. I don't mean I want
to change the drop-down options of the second box, I just want to have it
filled in with one of these options.

Here is code I have in the AfterUpdate event of the first combo box.
Qx14Out is the second combo box. The outcome codes are always the first
column of the option box:

Private Sub Qx14CallOut1_AfterUpdate()
Dim strOut As String
If Me.Qx14CallOut1 = "03" Then
strOut = "05"
ElseIf Me.Qx14CallOut1 = "04" Then
strOut = "02"
ElseIf Me.Qx14CallOut1 = "06" Then
strOut = "06"
End If

If strOut <> "" Then
Me!Qx14Out = strOut
Me.Refresh
End If
End Sub

Basically now, nothing is happening when I update the first box. There must
obviously be something different about combo boxes, because I can easily
update a text box this way...?

Thanks much - Terri
 
J

Jeff Boyce

What are the fields feeding the comboboxes? That is, what query/SQL
statement/value list are you using?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

Maverick

Here are a couple of suggestions:

1) Move this to the BeforeUpdate event.

2) Test the values of the field. Do this either in the Immediate Window or
simply create an unbound textbox and use the calculation of =[Qx14CallOut1]

3) Instead of

If strOut <> "" Then

Try using

If nZ(strOut,"") <> "" Then

This is a much better test for Null as it tests for both Null and empty
string.
 
T

Terri

I am using value lists on both forms (this is an addition to an older system
I developed several years ago!):

For Qx14CallOut1: 01;"Did Not Receive, Resend";02;"Received, Will
Return";03;"Refusal";04;"Telephone Interview";05;"Unable to
Reach";06;"Subject Deceased"

For Qx14Out: 01;"Complete";02;"Telephone Interview Complete";03;"Partial
Complete - Final";04;"Partial Complete - Needs
Call";05;"Refusal";06;"Deceased";07;"Incompetent/Too Ill/Language
Problem";08;"Lost to Followup";09;"Returned from Post Office";10;"Mailed,
Questionnaire Pending"
 
T

Terri

Oh sheesh. I just realized that I had the wrong column bound in Qx14Out, so
it was not showing the code. I changed it to the correct column and now
everything works fine... Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top