PC Review


Reply
Thread Tools Rate Thread

disabling field under specific conditions

 
 
=?Utf-8?B?dmFzc2lsaXM=?=
Guest
Posts: n/a
 
      3rd Dec 2006
hello...
i was trying to find a way , some fields in a form get appeard disabled (you
can nt import value) if, for example another column had a specific value .
is that possible? thanks
 
Reply With Quote
 
 
 
 
=?Utf-8?B?dmFzc2lsaXM=?=
Guest
Posts: n/a
 
      9th Dec 2006
hello Duane thanks for your replay but can u be more specific pls because i
have no
idea about coding ....i have a form(B) with a field "cost" , this form is a
subform in another form (A) with a field "speciality" (for
example)....everytime where "speciality" take a pecific value "AA" the "cost"
field to get disabled...
thanks


"Duane Hookom" wrote:

> You can create a function or sub in your form's module like:
>
> Sub DisableSome()
> If Me.chkSomeField = False Then
> Me.txtDateField.Enabled = False
> Else
> Me.txtDateField.Enabled = True
> End If
> End Sub
>
> You could then call this sub from the On Current event of the form and the
> After Update event of chkSomeField.
> --
> Duane Hookom
> Microsoft Access MVP
>
>
> "vassilis" wrote:
>
> > hello...
> > i was trying to find a way , some fields in a form get appeard disabled (you
> > can nt import value) if, for example another column had a specific value .
> > is that possible? thanks

 
Reply With Quote
 
=?Utf-8?B?RHVhbmUgSG9va29t?=
Guest
Posts: n/a
 
      9th Dec 2006
Open the main form in design view and find the On Current event of the form.
Double-click the On Current event to display:
On Current: [Event Procedure]
Then click the [...] to the right of this property to display the module
window for your form.

Your code window should display:

Private Sub Form_Current()

End Sub

Add this line:

Private Sub Form_Current()
DisableSome
End Sub

Then add this code below the End Sub

Sub DisableSome()
'change the control names to match yours
If Me.txtSpecialy = "AA" Then
Me.sfrmName.Form!txtCost.Enabled = False
Else
Me.sfrmName.Form!txtCost.Enabled = True
End If
End Sub

Then add code to the After Update event to the control txtSpecialty

Private Sub txtSpecialty_AfterUpdate()
DisableSome
End Sub

This should disable the txtCost control on your subform when txtSpecialty on
your main form has the value "AA".
--
Duane Hookom
Microsoft Access MVP


"vassilis" wrote:

> hello Duane thanks for your replay but can u be more specific pls because i
> have no
> idea about coding ....i have a form(B) with a field "cost" , this form is a
> subform in another form (A) with a field "speciality" (for
> example)....everytime where "speciality" take a pecific value "AA" the "cost"
> field to get disabled...
> thanks
>
>
> "Duane Hookom" wrote:
>
> > You can create a function or sub in your form's module like:
> >
> > Sub DisableSome()
> > If Me.chkSomeField = False Then
> > Me.txtDateField.Enabled = False
> > Else
> > Me.txtDateField.Enabled = True
> > End If
> > End Sub
> >
> > You could then call this sub from the On Current event of the form and the
> > After Update event of chkSomeField.
> > --
> > Duane Hookom
> > Microsoft Access MVP
> >
> >
> > "vassilis" wrote:
> >
> > > hello...
> > > i was trying to find a way , some fields in a form get appeard disabled (you
> > > can nt import value) if, for example another column had a specific value .
> > > is that possible? thanks

 
Reply With Quote
 
=?Utf-8?B?dmFzc2lsaXM=?=
Guest
Posts: n/a
 
      10th Dec 2006
Thanks!!!

"Duane Hookom" wrote:

> Open the main form in design view and find the On Current event of the form.
> Double-click the On Current event to display:
> On Current: [Event Procedure]
> Then click the [...] to the right of this property to display the module
> window for your form.
>
> Your code window should display:
>
> Private Sub Form_Current()
>
> End Sub
>
> Add this line:
>
> Private Sub Form_Current()
> DisableSome
> End Sub
>
> Then add this code below the End Sub
>
> Sub DisableSome()
> 'change the control names to match yours
> If Me.txtSpecialy = "AA" Then
> Me.sfrmName.Form!txtCost.Enabled = False
> Else
> Me.sfrmName.Form!txtCost.Enabled = True
> End If
> End Sub
>
> Then add code to the After Update event to the control txtSpecialty
>
> Private Sub txtSpecialty_AfterUpdate()
> DisableSome
> End Sub
>
> This should disable the txtCost control on your subform when txtSpecialty on
> your main form has the value "AA".
> --
> Duane Hookom
> Microsoft Access MVP
>
>
> "vassilis" wrote:
>
> > hello Duane thanks for your replay but can u be more specific pls because i
> > have no
> > idea about coding ....i have a form(B) with a field "cost" , this form is a
> > subform in another form (A) with a field "speciality" (for
> > example)....everytime where "speciality" take a pecific value "AA" the "cost"
> > field to get disabled...
> > thanks
> >
> >
> > "Duane Hookom" wrote:
> >
> > > You can create a function or sub in your form's module like:
> > >
> > > Sub DisableSome()
> > > If Me.chkSomeField = False Then
> > > Me.txtDateField.Enabled = False
> > > Else
> > > Me.txtDateField.Enabled = True
> > > End If
> > > End Sub
> > >
> > > You could then call this sub from the On Current event of the form and the
> > > After Update event of chkSomeField.
> > > --
> > > Duane Hookom
> > > Microsoft Access MVP
> > >
> > >
> > > "vassilis" wrote:
> > >
> > > > hello...
> > > > i was trying to find a way , some fields in a form get appeard disabled (you
> > > > can nt import value) if, for example another column had a specific value .
> > > > is that possible? thanks

 
Reply With Quote
 
=?Utf-8?B?dmFzc2lsaXM=?=
Guest
Posts: n/a
 
      10th Dec 2006
Hello Duane
the code is working fine, i would like to ask u if its possible to add more
values into the ....If Me.txtSpecialy = "AA" Then...sentence , "AA, BB,CC"
is it valid?
and to be more annoying , what changes can be made for disabling more
txtBoxes?
in the example below we disabled the txtCost ...
if you have time only ...

"Duane Hookom" wrote:

> Open the main form in design view and find the On Current event of the form.
> Double-click the On Current event to display:
> On Current: [Event Procedure]
> Then click the [...] to the right of this property to display the module
> window for your form.
>
> Your code window should display:
>
> Private Sub Form_Current()
>
> End Sub
>
> Add this line:
>
> Private Sub Form_Current()
> DisableSome
> End Sub
>
> Then add this code below the End Sub
>
> Sub DisableSome()
> 'change the control names to match yours
> If Me.txtSpecialy = "AA" Then
> Me.sfrmName.Form!txtCost.Enabled = False
> Else
> Me.sfrmName.Form!txtCost.Enabled = True
> End If
> End Sub
>
> Then add code to the After Update event to the control txtSpecialty
>
> Private Sub txtSpecialty_AfterUpdate()
> DisableSome
> End Sub
>
> This should disable the txtCost control on your subform when txtSpecialty on
> your main form has the value "AA".
> --
> Duane Hookom
> Microsoft Access MVP
>
>
> "vassilis" wrote:
>
> > hello Duane thanks for your replay but can u be more specific pls because i
> > have no
> > idea about coding ....i have a form(B) with a field "cost" , this form is a
> > subform in another form (A) with a field "speciality" (for
> > example)....everytime where "speciality" take a pecific value "AA" the "cost"
> > field to get disabled...
> > thanks
> >
> >
> > "Duane Hookom" wrote:
> >
> > > You can create a function or sub in your form's module like:
> > >
> > > Sub DisableSome()
> > > If Me.chkSomeField = False Then
> > > Me.txtDateField.Enabled = False
> > > Else
> > > Me.txtDateField.Enabled = True
> > > End If
> > > End Sub
> > >
> > > You could then call this sub from the On Current event of the form and the
> > > After Update event of chkSomeField.
> > > --
> > > Duane Hookom
> > > Microsoft Access MVP
> > >
> > >
> > > "vassilis" wrote:
> > >
> > > > hello...
> > > > i was trying to find a way , some fields in a form get appeard disabled (you
> > > > can nt import value) if, for example another column had a specific value .
> > > > is that possible? thanks

 
Reply With Quote
 
=?Utf-8?B?RHVhbmUgSG9va29t?=
Guest
Posts: n/a
 
      10th Dec 2006
It sounds like you are 'growing' new conditions. Is this going to continue or
is there a limited number of conditions and functionality that will be
finite? Once you get beyond a couple instances, you are better off (IMHO)
managing this with data.

AA, BB,CC must have something in common that should be stored in a table and
used from your code. You should be maintaining data records, not code.

Otherwise, you can use
If Me.txtSpecialy = "AA" Or Me.txtSpecialty ="BB" or Me.txtSpecialty = "CC"
Then

or

If Instr("AABBCC", Me.txtSpecialty) > 0 Then

--
Duane Hookom
Microsoft Access MVP


"vassilis" wrote:

> Hello Duane
> the code is working fine, i would like to ask u if its possible to add more
> values into the ....If Me.txtSpecialy = "AA" Then...sentence , "AA, BB,CC"
> is it valid?
> and to be more annoying , what changes can be made for disabling more
> txtBoxes?
> in the example below we disabled the txtCost ...
> if you have time only ...
>
> "Duane Hookom" wrote:
>
> > Open the main form in design view and find the On Current event of the form.
> > Double-click the On Current event to display:
> > On Current: [Event Procedure]
> > Then click the [...] to the right of this property to display the module
> > window for your form.
> >
> > Your code window should display:
> >
> > Private Sub Form_Current()
> >
> > End Sub
> >
> > Add this line:
> >
> > Private Sub Form_Current()
> > DisableSome
> > End Sub
> >
> > Then add this code below the End Sub
> >
> > Sub DisableSome()
> > 'change the control names to match yours
> > If Me.txtSpecialy = "AA" Then
> > Me.sfrmName.Form!txtCost.Enabled = False
> > Else
> > Me.sfrmName.Form!txtCost.Enabled = True
> > End If
> > End Sub
> >
> > Then add code to the After Update event to the control txtSpecialty
> >
> > Private Sub txtSpecialty_AfterUpdate()
> > DisableSome
> > End Sub
> >
> > This should disable the txtCost control on your subform when txtSpecialty on
> > your main form has the value "AA".
> > --
> > Duane Hookom
> > Microsoft Access MVP
> >
> >
> > "vassilis" wrote:
> >
> > > hello Duane thanks for your replay but can u be more specific pls because i
> > > have no
> > > idea about coding ....i have a form(B) with a field "cost" , this form is a
> > > subform in another form (A) with a field "speciality" (for
> > > example)....everytime where "speciality" take a pecific value "AA" the "cost"
> > > field to get disabled...
> > > thanks
> > >
> > >
> > > "Duane Hookom" wrote:
> > >
> > > > You can create a function or sub in your form's module like:
> > > >
> > > > Sub DisableSome()
> > > > If Me.chkSomeField = False Then
> > > > Me.txtDateField.Enabled = False
> > > > Else
> > > > Me.txtDateField.Enabled = True
> > > > End If
> > > > End Sub
> > > >
> > > > You could then call this sub from the On Current event of the form and the
> > > > After Update event of chkSomeField.
> > > > --
> > > > Duane Hookom
> > > > Microsoft Access MVP
> > > >
> > > >
> > > > "vassilis" wrote:
> > > >
> > > > > hello...
> > > > > i was trying to find a way , some fields in a form get appeard disabled (you
> > > > > can nt import value) if, for example another column had a specific value .
> > > > > is that possible? thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to lock records until specific conditions are met? Ernie Lippert Microsoft Access VBA Modules 1 4th Dec 2008 03:57 AM
an excel formula for specific conditions =?Utf-8?B?c3Jpbml2YXNhbg==?= Microsoft Excel Worksheet Functions 1 27th Mar 2006 06:20 AM
RE: an excel formula for specific conditions =?Utf-8?B?RnJhbmtzdGE=?= Microsoft Excel Worksheet Functions 0 26th Mar 2006 11:49 PM
RE: an excel formula for specific conditions =?Utf-8?B?RnJhbmtzdGE=?= Microsoft Excel Worksheet Functions 0 26th Mar 2006 11:49 PM
Conditions for disabling net connxn? Chris Windows XP Networking 0 5th Nov 2003 11:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:12 AM.