Select Case New Entry

  • Thread starter newbie via AccessMonster.com
  • Start date
N

newbie via AccessMonster.com

Hi

I was wondering if someone can help me out -

I have a textbox whereby it's entry is dependent on which of 3 buttons is
pressed. By clicking one of the buttons, it populates the textbox with an
answer and disables the other 2 buttons...

The buttons are btnAchieved(1), btnFailed(2), btnUnverify(3). - so if i click
achieved, then btn1 and 2 become disabled and only btn3 can be pressed. the
textbox(pm_result) will say ACHIEVED.

this is the following code i have writen withn Form_current to determine what
buttons are enabled/disabled

With Me
Select Case Me.PM_RESULT
Case "Achieved"
.btnAchieved.Enabled = False
.btnFailed.Enabled = False
.btnUnverify.Enabled = True

Case "Not Achieved"
.btnAchieved.Enabled = False
.btnFailed.Enabled = False
.btnUnverify.Enabled = True

Case "Unverified"
.btnAchieved.Enabled = True
.btnFailed.Enabled = True
.btnUnverify.Enabled = False
End Select
End With

HOWEVER - the textbox starts off empty - so im trying to add a 'case' to the
above coding to say that if the textbox is empty then btn1 + btn2 are enabled
and btn3 is not however i have no idea how to define it!

i've tried Case is Null and Case "" but it doesnt work
Does anyone have any suggestions??
 
J

jmonty

I think you may inadvertantly be pulling extra spaces.
Try trimming the field first:

Select Case Trim(Me.PM_RESULT)

If that still odes not work, try testing for the length:

If Len(Trim(Me.PM_RESULT)) >0 Then
Case "Achieved"
.btnAchieved.Enabled = False
.btnFailed.Enabled = False
.btnUnverify.Enabled = True
Case "Not Achieved"
.btnAchieved.Enabled = False
.btnFailed.Enabled = False
.btnUnverify.Enabled = True
Case "Unverified"
.btnAchieved.Enabled = True
.btnFailed.Enabled = True
.btnUnverify.Enabled = False
End Select
Else
'Place your default setting here
End If



jmonty
 
P

Powderfinger

I like JMontys solution but FYI you can always use Case Else to set off an
alternative action , i.e.


Select Case Me.PM_RESULT
Case "Achieved"
.btnAchieved.Enabled = False
.btnFailed.Enabled = False
.btnUnverify.Enabled = True

Case "Not Achieved"
.btnAchieved.Enabled = False
.btnFailed.Enabled = False
.btnUnverify.Enabled = True

Case "Unverified"
.btnAchieved.Enabled = True
.btnFailed.Enabled = True
.btnUnverify.Enabled = False

Case Else
.btnAchieved.Enabled = True
.btnFailed.Enabled = True
.btnUnverify.Enabled = False

End Select
 
R

RoyVidar

newbie via AccessMonster.com said:
Hi

I was wondering if someone can help me out -

I have a textbox whereby it's entry is dependent on which of 3
buttons is pressed. By clicking one of the buttons, it populates the
textbox with an answer and disables the other 2 buttons...

The buttons are btnAchieved(1), btnFailed(2), btnUnverify(3). - so if
i click achieved, then btn1 and 2 become disabled and only btn3 can
be pressed. the textbox(pm_result) will say ACHIEVED.

this is the following code i have writen withn Form_current to
determine what buttons are enabled/disabled

With Me
Select Case Me.PM_RESULT
Case "Achieved"
.btnAchieved.Enabled = False
.btnFailed.Enabled = False
.btnUnverify.Enabled = True

Case "Not Achieved"
.btnAchieved.Enabled = False
.btnFailed.Enabled = False
.btnUnverify.Enabled = True

Case "Unverified"
.btnAchieved.Enabled = True
.btnFailed.Enabled = True
.btnUnverify.Enabled = False
End Select
End With

HOWEVER - the textbox starts off empty - so im trying to add a 'case'
to the above coding to say that if the textbox is empty then btn1 +
btn2 are enabled and btn3 is not however i have no idea how to define
it!

i've tried Case is Null and Case "" but it doesnt work
Does anyone have any suggestions??

You could try experiment with something like this

Dim fToggle as Boolean
With Me
fToggle = ((Len(!PM_RESULT & vbNullString)=0) _
OR (!PM_RESULT = "Achieved") _
OR (!PM_RESULT = "Not Achieved"))
!btnAchieved.Enabled = fToggle
!btnFailed.Enabled = fToggle
!btnUnverify.Enabled = Not fToggle
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top