I have a 2 button option group that I am using to allow users to answer a question yes or no. There is a text field in a table that holds the value "Y" or "N" for the question response. On the form where the un bounded option group resides I have created a VBA event procedure for each button when the mouse is clicked(mouse down). The procedures set a text box on the form to "Y" or "N". The text box control source is the text field in the table. The buttons work correctly updating the table value but the "No" button behavior on the form is not right. When the "Yes" button is clicked it turns on with the blue center. If the "No" button is pressed the vba procedure runs correctly but the button does not turn blus and the focus reverts back to the Yes button (dotted line around the YES label). Any idea why is happening? Thank you. Access 2013 running on Win 7.
Incorrect button behavior inside option group
Collapse
X
-
Here is the code for the 2 buttons. Q1_Response is the text box on the form. I also have a screen shot right after the No button is pressed. Q1_Response is also in the screen shot properly updated to "N".
Code:Private Sub Option787_MouseDown(Button As Integer, Shift As Integer, X2 As Single, Y2 As Single) Q1_Response = "Y" End Sub Private Sub Option789_MouseDown(Button As Integer, Shift As Integer, X2 As Single, Y2 As Single) Q1_Response = "N" End Sub
Attached FilesLast edited by Rabbit; Sep 15 '15, 03:43 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.Comment
-
If I understand you correctly, you are using an unbound option group to update a bound textbox control. Your code appears to update the table value for Q1_Response, but not the option group. Each radio in the option group has a value and this value is not being updated. Add something like:
[option group name] = "N"
Would it not be easier to create a bound option group so it stores your selection? In design view, click on the option group and set its control source to the field.Comment
-
Thanks for your reply, I now have it working. The problem with directly bounding the option group was that the radio buttons are numeric and the field I'm updating is text. Adding the statement:
[Option group name]=1 (or 2) solved the button issue. Thanks again!Comment
Comment