Hi Burbonizer,

See if the following does what you want.  It modifies your code to require
both conditions for the field you printed in red to be made visible.  If
either condition is false, the field is made invisible again.

If me.active_statuts = "IH"  then

    Me.Input1.SetFocus

    Me.Button_PO1.Enabled = False

    Me.Button_VD.Enabled = False

    Me.Button_SP.Enabled = False

    Me.Command107.Enabled = False

    Me.Button_DO.Enabled = False

    Me.Button_H.Enabled = False

    Me.Button_R.Enabled = False

    Me.Button_TS.Enabled = False

    Me.Button_IH.Enabled = False

    Me.Button_ALS.Enabled = False

    Me.Button_AL.Enabled = False

    Me.Button_AL1.Enabled = False

    Me.Button_Awaiting_Inspection.Enabled = True

    Me.Button_PS.Enabled = False

    Me.Button_AIAP.Enabled = False

    Me.Button_AIOH.Enabled = False

    Me.Button_OH.Enabled = True

    Me.Button_AP.Enabled = True

    Me.Button_C.Enabled = False

    Me.Button_AD.Enabled = False

    Me.Button_PO2.Enabled = False

    Me.Button_AL1PO.Enabled = False

    Me.Button_EM.Enabled = False

    Me.Command106.Visible = False

    if me.location = "Specialist Production" then 

        me.Moved_to_Vehicles.Visible = true

    else

        Me.Moved_to_Vehicles.Visible = false

    end if

else

    Me.Moved_to_Vehicles.Visible = false

End If

 

If this is not what you are looking for, please explain the logic you need
more precisely, or the problem you are having (for example, are you getting
a runtime error?).  It would also be very helpful to see you file.  You can
make a copy with the data deleted and a few example records of dummy data in
its place.

 

Asa

 

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of Burbonizer
Sent: Thursday, May 17, 2012 3:23 AM
To: excel-macros@googlegroups.com
Subject: $$Excel-Macros$$ VBA If statement

 

 

Hi All,

 i currently have a form that has button's on it which are enabled via code
if a field contains certain data.

 

I now want another button to become visible if a field contains some text
and another field contains some text.

 

basically in english terms i need to following but can not get the syntax to
work. The red text is what i need to add.

 

If me.active_statuts = "IH"  then

Me.Input1.SetFocus
Me.Button_PO1.Enabled = False
Me.Button_VD.Enabled = False
Me.Button_SP.Enabled = False
Me.Command107.Enabled = False
Me.Button_DO.Enabled = False
Me.Button_H.Enabled = False
Me.Button_R.Enabled = False
Me.Button_TS.Enabled = False
Me.Button_IH.Enabled = False
Me.Button_ALS.Enabled = False
Me.Button_AL.Enabled = False
Me.Button_AL1.Enabled = False
Me.Button_Awaiting_Inspection.Enabled = True
Me.Button_PS.Enabled = False
Me.Button_AIAP.Enabled = False
Me.Button_AIOH.Enabled = False
Me.Button_OH.Enabled = True
Me.Button_AP.Enabled = True
Me.Button_C.Enabled = False
Me.Button_AD.Enabled = False
Me.Button_PO2.Enabled = False
Me.Button_AL1PO.Enabled = False
Me.Button_EM.Enabled = False
Me.Command106.Visible = False
Me.Moved_to_Vehicles.Visible = false

End If

if me.location = "Specialist Production" then 

me.Moved_to_Vehicles.Visible = true

end if

 

But i dont want the button to appear if only one of these fields contains
the correct data. I need both to be true to do my bit.

 

Any help would be great.

Thanks

-- 
FORUM RULES (986+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security
measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
 
----------------------------------------------------------------------------
--------------------------
To post to this group, send email to excel-macros@googlegroups.com

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to