changing Default Value after clicking

Bonzay0

Registered User.
Local time
Today, 15:42
Joined
Apr 16, 2009
Messages
17
I have an Option Group with 3 buttons and the default one is the first button
meaning 1
I want that after a user press the second button the default will be 2 (the one I clicked on)
I tried to use the code:
Code:
Private Sub option20_GotFocus()
frame17.DefaultValue = 2
End Sub

and it didnt work (most likely not even the correct command use)
any one can help (I'am really newbie)
 
Firstly welcome to the forum.

You could use something like the following in the On Click event of your Option Group

Code:
Private Sub Frame17_Click()
    
    Me.Frame17.DefaultValue = Me.Frame17
    
End Sub

This will set the default value of your option group to the last value you clicked on.
 
1) I cant use Click it doesn't have a option to add a code to a click
2) I tried the same code you gave me and it didn't work (tried to change the Me.Frame17 to Me.Option22 and that 2 didn't work...)
when i go to main menu and back it still on 1
 
Firstly put the form into design view. Ensure that the properties box is visible.

Now click on the Frame/Option Group.

Now click on the Events Tab in the properties box. Click in the On Click event. Click on the drop down and select [Event Procedure]. Now click on the construct button, that's the one next to the drop down arrow with the three full stops in it.

Now paste;

Code:
Me.Frame0.DefaultValue = Me.Frame0

Between the Private Sub and End Sub tags. ensure that you change Frame0 to match the name of your frame.
 
Can you post a copy of your DB, so I can try and see what's (not) going on?
 
There seems to be a compatibility issue with the Hebrew font. It Displays fine in the Form, but just comes out as gobbledy gook in the code window, and non of the buttons worked for me :mad:

Any way I've attached a small DB that uses the code I posted earlier. I've put the code to change the default in the On Click event of the Frame/Option Group and also on the forms On Current Event. I hope that helps you get it working.
 

Attachments

Try this code:

Private Sub frame17_AfterUpdate()

Select Case Me!frame17

Case 1
'your code
Me.frame17.DefaultValue = 1

Case 2
'your code
Me.frame17.DefaultValue = 2

Case 3
'your code
Me.frame17.DefaultValue = 3

End Select
Exit Sub

end sub
 
Last edited:
somthing really wierd the default value doesn't change at my form but in your it does...

and editolis your code 2 is'nt working
 
i tried to change default value to a text box and it wont change it either...
what option can cause all things on the form not to be able to change the default value?
 

Users who are viewing this thread

Back
Top Bottom