A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

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



 
 
Thread Tools Display Modes
  #1  
Old November 28th, 2009, 04:07 AM posted to microsoft.public.access.forms
BobC[_6_]
external usenet poster
 
Posts: 89
Default I want to inhibit editing of one text box based on the content ofanother

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
  #2  
Old November 28th, 2009, 04:54 AM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default I want to inhibit editing of one text box based on the content of another

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"

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #3  
Old November 28th, 2009, 05:07 AM posted to microsoft.public.access.forms
BobC[_6_]
external usenet poster
 
Posts: 89
Default I want to inhibit editing of one text box based on the contentof another

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"

  #4  
Old November 28th, 2009, 06:56 AM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default I want to inhibit editing of one text box based on the content of another

On Sat, 28 Nov 2009 00:07:23 -0500, BobC wrote:

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?
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #5  
Old November 28th, 2009, 07:21 AM posted to microsoft.public.access.forms
BobC[_6_]
external usenet poster
 
Posts: 89
Default I want to inhibit editing of one text box based on the contentof another

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

fredg wrote:
On Sat, 28 Nov 2009 00:07:23 -0500, BobC wrote:

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?

  #6  
Old November 28th, 2009, 12:02 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default I want to inhibit editing of one text box based on the content of another

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
http://I.Am/DougSteele
(no e-mails, please!)



"BobC" wrote in message
...
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

fredg wrote:
On Sat, 28 Nov 2009 00:07:23 -0500, BobC wrote:

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?


  #7  
Old November 28th, 2009, 03:04 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default I want to inhibit editing of one text box based on the content of another

Fred's code, placed as he's advised, will do the job.

There were two problems with your code:

First, you followed

me.Status = "Ship Requested"

with a semi-colon, instead of a comma, which was the cause of the

'Expected: list separator or )'

error message.

Secondly, IIF() is intended to be used to populate a value into a field. It
would use syntax like this

Me.Textbox = IIF(Me.Status = "Ship Requested", "ThisValue", "ThatValue")

It cannot be use to set a form's property, as you tried to do.

As always when doing this kind of thing, you need to have some strategy in
place for dealing with the user incorrectly entering "Ship Requested" in the
Status field. And this will happen!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200911/1

  #8  
Old November 28th, 2009, 04:45 PM posted to microsoft.public.access.forms
BobC[_6_]
external usenet poster
 
Posts: 89
Default I want to inhibit editing of one text box based on the contentof another

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


Douglas J. Steele wrote:
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

  #9  
Old November 28th, 2009, 04:52 PM posted to microsoft.public.access.forms
BobC[_6_]
external usenet poster
 
Posts: 89
Default I want to inhibit editing of one text box based on the contentof another

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

Linq Adams via AccessMonster.com wrote:
Fred's code, placed as he's advised, will do the job.

There were two problems with your code:

First, you followed

me.Status = "Ship Requested"

with a semi-colon, instead of a comma, which was the cause of the

'Expected: list separator or )'

error message.

Secondly, IIF() is intended to be used to populate a value into a field. It
would use syntax like this

Me.Textbox = IIF(Me.Status = "Ship Requested", "ThisValue", "ThatValue")

It cannot be use to set a form's property, as you tried to do.

As always when doing this kind of thing, you need to have some strategy in
place for dealing with the user incorrectly entering "Ship Requested" in the
Status field. And this will happen!

  #10  
Old November 28th, 2009, 05:22 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default I want to inhibit editing of one text box based on the content of another

Placing it in the AfterUpdate event of the Status control will set the
AllowEdit Property as soon as the Status control has a value entered.

Placing it in the Form_Current event insures that when you move from one
record to another, the Property is set appropriately.

For example, if you ***only*** place it in the Status_AfterUpdate event, and
the value entered is "Ship Requested," the AllowEdits would be set to True.

If you then move to another record, where the value of Status is something
other than "Ship Requested," AllowEdits will still be set to Yes, because
nothing ha been done to check the current value of Status!

Having the code in the Form_Update event checks the value of Status as you
move to a new record and sets AllowEdits accordingly.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200911/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.