Option Button - Code Error.

kostaskir

Registered User.
Local time
Today, 04:22
Joined
Jan 21, 2009
Messages
65
Hi guys,

I have a Button and a radio button. The scenario is very simple.

Everytime I click the Button (Apply), my code should check If the Radio button = True Then Execute a Query.

So I wrote this :

PHP:
Dim strSQL As String
Dim Arial_f As OptionButton

If Arial_f.Enabled = True Then

strSQL = "UPDATE Settings SET fontname= 1"
DoCmd.RunSQL strSQL

End If


I receive the following error:

Run time error 91
Object variable or With block variable not set

Any ideas ?

How is the correct syntax for an Option Button ?


Thanx in advance.
 
This is what I think you need:

Code:
Dim strSQL As String

If me.Arial_f.value = True Then

strSQL = "UPDATE Settings SET fontname= 1"
DoCmd.RunSQL strSQL

End If

The Dim statement will set Arial_f as a variable. But this is not what you want. Instead you simply refer to the object on the form (me.Arial_f).

Also, I assume you are interested in the value of the button? Therefore use the value attribute. The "enabled" attribute gets/sets whether the object is usable or not i.e. whether the user is able to click on it. I suspect that is not what you want.

hth
Chris
 
I found how it works !

Thank you for your help
 

Users who are viewing this thread

Back
Top Bottom