IF statement not working

BlueFraggle

Registered User.
Local time
Today, 13:29
Joined
Jul 25, 2007
Messages
10
Hi everyone, I am hoping one of you kind souls will be able to help me.

I have the following piece of code (in the OnCurrent Event Procedue of a form):

Code:
If Me.[Type] = "Sample" And Me.[Interface] = "N/A" Then
        Me![Button 1].Enabled = True
        Me![Button 2].Enabled = True
        Me![Button 3].Enabled = True
End If


However it is not working as required. If Type = "Sample" but Interface does not equal "N/A" the 3 button are still enabled.

I dont think the AND part of the IF statement is working. I need both statements to be True for the buttons to be enabled.

Any ideas?

Thanks
 
Try
Code:
If (Me.[Type] = "Sample") And (Me.[Interface] = "N/A") Then
        Me![Button 1].Enabled = True
        Me![Button 2].Enabled = True
        Me![Button 3].Enabled = True
End If
 
Many thanks for your help.

Unfortunately I have tried your suggestion but it is still not working

When the Type = "Sample" the buttons are enabled no matter what the Interface is set to.

I require both statements to be True for the buttons to be enabled.

Do you know if there is something simple that I am missing or getting wrong.

As a test I have just placed a text box on my form and set the control source to :

Code:
=IIf([Type]="Sample" And [Interface]="N/A","Hello","Goodbye")

This works fine.

However the code to enable/disable the button does not.
 
I cant see any code to disable the buttons. why not try with an else statement to disable them

Code:
If (Me.[Type] = "Sample") And (Me.[Interface] = "N/A") Then
        Me![Button 1].Enabled = True
        Me![Button 2].Enabled = True
        Me![Button 3].Enabled = True
Else
        Me![Button 1].Enabled = false
        Me![Button 2].Enabled = false
        Me![Button 3].Enabled = false
End If
 
Thats work superb.

My next question then is how do I get Buttons 4,5 and 6 to be enabled IF Type = "Product" AND Interface = "N/A" ?

Your help is very much appreciated.
 
try this
Code:
If (Me.[Type] = "Product") And (Me.[Interface] = "N/A") Then
        Me![Button 4].Enabled = True
        Me![Button 5].Enabled = True
        Me![Button 6].Enabled = True
Else
        Me![Button 4].Enabled = false
        Me![Button 5].Enabled = false
        Me![Button 6].Enabled = false
End If
 
Just a quick message to say many thanks for your help.

Eerything is now working as I require.

Cheers
 

Users who are viewing this thread

Back
Top Bottom