PC Review


Reply
Thread Tools Rate Thread

Disable-based on Adding New Record vs. Editing Existing fields

 
 
Steve Stad
Guest
Posts: n/a
 
      13th Jan 2010
Is there a way to disable and/or enable the same field(s) based on if a user
is editing an existing record or Adding a new record for a given criteria.
Here is an example for a given field in a matrix for 3 criteria for the same
field.

Edit Adding New Record
Criteria 1 Yes/Enable No/Disable
Criteria 2 Yes/Enable No/Disable
Criteria 3 Yes/Enable Yes/Enable

Let me know if I can provide any more explanation.
Thanks in advance for your assistance.

 
Reply With Quote
 
 
 
 
fredg
Guest
Posts: n/a
 
      13th Jan 2010
On Wed, 13 Jan 2010 09:28:02 -0800, Steve Stad wrote:

> Is there a way to disable and/or enable the same field(s) based on if a user
> is editing an existing record or Adding a new record for a given criteria.
> Here is an example for a given field in a matrix for 3 criteria for the same
> field.
>
> Edit Adding New Record
> Criteria 1 Yes/Enable No/Disable
> Criteria 2 Yes/Enable No/Disable
> Criteria 3 Yes/Enable Yes/Enable
>
> Let me know if I can provide any more explanation.
> Thanks in advance for your assistance.


The following will enable or not enable the [First Name] control
depending upon whether or not it is a new record or if the [LastName]
control is a specific value.
Place the following code in the Form's Current event:

If Me.NewRecord Then
Me.[First Name].Enabled = True
ElseIf Me.[LastName] = "Smith" Then
Me.[First Name].Enabled = True
Else
Me.[First Name].Enabled = False
End If

Place the same code din the [LastName] AfterUpdate event.

Change the control names to whatever your actual control names are.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 
Reply With Quote
 
Steve Stad
Guest
Posts: n/a
 
      14th Jan 2010
Thanks Fred - I tried your code and was able to disable a field but not
Enable it. I have it mixed with this current/existing code to disable fields
- so I may need to remove my current code (since it only accomplishes part of
what I need) and/or add to your If/Else statement.
Current Code
Private Sub EMP_TYPE_AfterUpdate()
EMP_FIRST_NAME.Enabled = (EMP_TYPE = "CTR")
EMPLOYEE_EMAIL_ADDRESS.Enabled = (EMP_TYPE = "CTR")
End Sub
Private Sub EMP_TYPE_GotFocus()
EMP_FIRST_NAME.Enabled = (EMP_TYPE = "CTR")
EMPLOYEE_EMAIL_ADDRESS.Enabled = (EMP_TYPE = "CTR")
End Sub

To explain further - What I am trying to do is....
If New Record AND Emp_type = "M" or "C" then DISable field1.
If it is an existing record and AND Emp_type = "M" or "C" then ENable field1.
If New Record AND Emp_type = "CTR" then ENable field1.
If it is existing record and Emp_type = "CTR" then ENable field1.

I will need to use the code/logic for several fields on one form. I suppose
I can repeat the code for fields 2,3,4, etc. Thanks - I am new to prgramming
- do I need to replace the me. with a form name?

"fredg" wrote:

> On Wed, 13 Jan 2010 09:28:02 -0800, Steve Stad wrote:
>
> > Is there a way to disable and/or enable the same field(s) based on if a user
> > is editing an existing record or Adding a new record for a given criteria.
> > Here is an example for a given field in a matrix for 3 criteria for the same
> > field.
> >
> > Edit Adding New Record
> > Criteria 1 Yes/Enable No/Disable
> > Criteria 2 Yes/Enable No/Disable
> > Criteria 3 Yes/Enable Yes/Enable
> >
> > Let me know if I can provide any more explanation.
> > Thanks in advance for your assistance.

>
> The following will enable or not enable the [First Name] control
> depending upon whether or not it is a new record or if the [LastName]
> control is a specific value.
> Place the following code in the Form's Current event:
>
> If Me.NewRecord Then
> Me.[First Name].Enabled = True
> ElseIf Me.[LastName] = "Smith" Then
> Me.[First Name].Enabled = True
> Else
> Me.[First Name].Enabled = False
> End If
>
> Place the same code din the [LastName] AfterUpdate event.
>
> Change the control names to whatever your actual control names are.
>
> --
> Fred
> Please respond only to this newsgroup.
> I do not reply to personal e-mail
> .
>

 
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
adding a new record at subform should update an existing record (not create new record) Mark Kubicki Microsoft Access Form Coding 1 16th Jan 2009 08:34 AM
Programmatically adding fields to table based on structure and content of a particular record rwfreeman Microsoft Access Form Coding 1 26th May 2007 05:02 AM
JS-Q9 Restricting available options on form, contrasting new record with editing existing record Jack Sheet Microsoft Access Getting Started 4 9th Nov 2005 12:38 PM
Goto an existing record based on the values in the new record Hallgeir Microsoft Access Form Coding 0 25th Jan 2005 02:41 PM
Create new record using a form based on an existing record =?Utf-8?B?QWxleA==?= Microsoft Access Forms 2 4th Nov 2004 02:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:03 PM.