I want to inhibit editing of one text box based on the content ofanother

  • Thread starter Thread starter BobC
  • Start date Start date
B

BobC

The two text boxes are on the same form (subform3).
I want to inhibit the Quantity filed from being edited if the Status
field contains "Ship Requested".

The following code gives me an error 'Expected: list separator or )'

Private Sub Quantity_BeforeUpdate(Cancel As Integer)
' Inhibit txtbox if the Status field is "Ship Requested"
IIf(me.Status = "Ship Requested"; me.AllowEdits = True, _
me.AllowEdits = False)
End Sub
 
The two text boxes are on the same form (subform3).
I want to inhibit the Quantity filed from being edited if the Status
field contains "Ship Requested".

The following code gives me an error 'Expected: list separator or )'

Private Sub Quantity_BeforeUpdate(Cancel As Integer)
' Inhibit txtbox if the Status field is "Ship Requested"
IIf(me.Status = "Ship Requested"; me.AllowEdits = True, _
me.AllowEdits = False)
End Sub


Code both the [Status] AfterUpdate event AND the Form's Current event:

Me.AllowEdits = [Status] = "Ship Requested"
 
I'm having a hard time with this...
Are you saying put the same equation in two locations?
I never saw two = signs in the same expression?

The two text boxes are on the same form (subform3).
I want to inhibit the Quantity filed from being edited if the Status
field contains "Ship Requested".

The following code gives me an error 'Expected: list separator or )'

Private Sub Quantity_BeforeUpdate(Cancel As Integer)
' Inhibit txtbox if the Status field is "Ship Requested"
IIf(me.Status = "Ship Requested"; me.AllowEdits = True, _
me.AllowEdits = False)
End Sub


Code both the [Status] AfterUpdate event AND the Form's Current event:

Me.AllowEdits = [Status] = "Ship Requested"
 
I'm having a hard time with this...
Are you saying put the same equation in two locations?
I never saw two = signs in the same expression?
The two text boxes are on the same form (subform3).
I want to inhibit the Quantity filed from being edited if the Status
field contains "Ship Requested".

The following code gives me an error 'Expected: list separator or )'

Private Sub Quantity_BeforeUpdate(Cancel As Integer)
' Inhibit txtbox if the Status field is "Ship Requested"
IIf(me.Status = "Ship Requested"; me.AllowEdits = True, _
me.AllowEdits = False)
End Sub


Code both the [Status] AfterUpdate event AND the Form's Current event:

Me.AllowEdits = [Status] = "Ship Requested"

Did you place it in the 2 locations?
Did you write the expression exactly as I wrote it?
What happened?
 
I did as you said and placed it in the two locations.
It worked logically backwards from what I wanted, so I changed the
equation to:
Me.AllowEdits = [Status] <> "Ship Requested"
It now works great! dispite the fact that I still do not understand it!

THANK YOU VERY MUCH!!!!!!!!

Bob
I'm having a hard time with this...
Are you saying put the same equation in two locations?
I never saw two = signs in the same expression?
On Fri, 27 Nov 2009 23:07:21 -0500, BobC wrote:

The two text boxes are on the same form (subform3).
I want to inhibit the Quantity filed from being edited if the Status
field contains "Ship Requested".

The following code gives me an error 'Expected: list separator or )'

Private Sub Quantity_BeforeUpdate(Cancel As Integer)
' Inhibit txtbox if the Status field is "Ship Requested"
IIf(me.Status = "Ship Requested"; me.AllowEdits = True, _
me.AllowEdits = False)
End Sub


Code both the [Status] AfterUpdate event AND the Form's Current event:

Me.AllowEdits = [Status] = "Ship Requested"

Did you place it in the 2 locations?
Did you write the expression exactly as I wrote it?
What happened?
 
AllowEdits is a boolean field (i.e.: it accepts True or False).

[Status] = "Ship Requested" and [Status] <> "Ship Requested" are boolean
expressions (i.e.: they return True or False)

I usually add parentheses to make it a little clearer:

Me.AllowEdits = ([Status] <> "Ship Requested")

Note that this is exactly the same as

If [Status] <> "Ship Requested" Then
Me.AllowEdits = True
Else
Me.AllowEdits = False
End If

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



BobC said:
I did as you said and placed it in the two locations.
It worked logically backwards from what I wanted, so I changed the
equation to:
Me.AllowEdits = [Status] <> "Ship Requested"
It now works great! dispite the fact that I still do not understand it!

THANK YOU VERY MUCH!!!!!!!!

Bob
I'm having a hard time with this...
Are you saying put the same equation in two locations?
I never saw two = signs in the same expression?

fredg wrote:
On Fri, 27 Nov 2009 23:07:21 -0500, BobC wrote:

The two text boxes are on the same form (subform3).
I want to inhibit the Quantity filed from being edited if the Status
field contains "Ship Requested".

The following code gives me an error 'Expected: list separator or )'

Private Sub Quantity_BeforeUpdate(Cancel As Integer)
' Inhibit txtbox if the Status field is "Ship Requested"
IIf(me.Status = "Ship Requested"; me.AllowEdits = True, _
me.AllowEdits = False)
End Sub


Code both the [Status] AfterUpdate event AND the Form's Current event:

Me.AllowEdits = [Status] = "Ship Requested"

Did you place it in the 2 locations?
Did you write the expression exactly as I wrote it?
What happened?
 
It is not clear to me why I place the expression in TWO locations?
And... By doing so, does it affect more than ONE text box?

Thank you for you explanation!
Bob
 
Thank you for your time in explaining the suntax and use of the IIF
function! I could swear that the syntax I read had a semicolon????

Can you explain why it needed to be placed in TWO locations and in doing
so how many text boxes it affects?

Thank You Again,
Bob
 
I was addressing your comment "It now works great! dispite the fact that I
still do not understand it!"

David was pointing out that my termininology was sloppy.
 
Back
Top