Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set combo value if check box is not checked...

Status
Not open for further replies.

VhbuiA

MIS
Oct 6, 2005
22
0
0
US
Hi, hopefully this is the right forum to post to.

Here's the background:

I have three controls on an unbound form:
1. Text box that gets its value from a combo box whose row source is a query
2. I have another combo box whose row source is a table
3. I have a check box

What I want is to have control # 2 be set to whatever value is in control # 1 whenever control # 3 is Not checked. If control # 3 is checked, I want to set the focus to control # 2 to have the user select the appropriate response.

Here's the code I have but only 1/2 of it is working. Basically if the check box is selected, it will perform the set focus...but if it is unselected, it doesn't default the value to control # 1. Do you think it has to do with the combo's row source?

If Me.chkYes.Value = True Then
comboA.SetFocus
Else
comboA.Value = Me.txtA.Value
End If

Any help is greatly appreciated! Thanks!
 
You seem to be refering to 4 separate controls in your description. You have 3 controls, but #1 is a TEXTBOX that gets its value from a combobox whose row source is a query. #2 is a combobox whose row source is a table, therefore NOT the combobox refered to in #1. and #3 is a check box.

What is this 4th control?
 
Hello:

I agree with the previous poster. Something has to initially fire the event. Below is an example of what would work if you cleared your check box:
'
Private Sub chkControl3_Click()
If chkControl3 = True Then txtControl2.SetFocus
'
If chkControl3 = False Then
txtControl1.Value = txtControl2.Value
'txtControl2.Text = txtControl1.Text
End If

End Sub

Regards
Mark
 
Code minus the remarked line:

Private Sub chkControl3_Click()
If chkControl3 = True Then txtControl2.SetFocus
'
If chkControl3 = False Then
txtControl1.Value = txtControl2.Value
End If

End Sub
 
Thanks for responding!

Sorry for the confusion...I do have more controls on the form itself but only the three mentioned is related to what I'm trying to accomplish. The fourth control was just additional information regarding the text box.

I'll give mhartman1's suggestion a try and see what happens.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top