disable data entry/editing for rest of form if condition is met

  • Thread starter Thread starter reservedbcreater
  • Start date Start date
R

reservedbcreater

i have a field called community
if they pic yes (yes,no,n/a,uknown)
i want the rest of the form's fields to be locked so the user cannot enter
any data in them, if no other other, the user can fill in those boxes
 
You might try:

if pic = "yes" then
me.allowedits = false
else
me.allowedits = true
end if

HTH,
Debbie


|i have a field called community
| if they pic yes (yes,no,n/a,uknown)
| i want the rest of the form's fields to be locked so the user cannot enter
| any data in them, if no other other, the user can fill in those boxes
|
 
this is great but where do i put that code
it doesnt work like this...
because my forms open blank(like suppsoed to)- all fields are
blank(CommunityGarbageDisposal being one) so it makes edits not allowed
and u cant do anything

i need it so u can edit anything until u fill out YES for
CommunityGarbageDisposal
then every other field on the form gets locked, but if u pick no or its
blank everything else is alowed to be eddited


doesnt work:

Private Sub Form_Current()
On Error GoTo Err_cmdClose_Click

If CommunityGarbageDisposal = "YES" Then
Me.AllowEdits = False
Else
Me.AllowEdits = True
End If

Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click

End Sub
 
I'm assuming that CommunityGarbageDisposal is a combo box. You could put the code in the field's AfterUpdate event.

HTH,
Debbie


| this is great but where do i put that code
| it doesnt work like this...
| because my forms open blank(like suppsoed to)- all fields are
| blank(CommunityGarbageDisposal being one) so it makes edits not allowed
| and u cant do anything
|
| i need it so u can edit anything until u fill out YES for
| CommunityGarbageDisposal
| then every other field on the form gets locked, but if u pick no or its
| blank everything else is alowed to be eddited
|
|
| doesnt work:
|
| Private Sub Form_Current()
| On Error GoTo Err_cmdClose_Click
|
| If CommunityGarbageDisposal = "YES" Then
| Me.AllowEdits = False
| Else
| Me.AllowEdits = True
| End If
|
| Exit_cmdClose_Click:
| Exit Sub
| Err_cmdClose_Click:
| MsgBox Err.Description
| Resume Exit_cmdClose_Click
|
| End Sub
|
 
but i dotn want it to happen after update ?? i want it to happen as soon as
they select an answer in the CommunityGarbageDisposal combo box
 
Did you try it?

This is from Access Developer's Handbook:

For list and combo boxes, Access raises the BeforeUpdate event just before it attempts to update the underlying record set, and the
AfterUpdate event occurs just after. You can attach code to either of these events to trap the selection event in either a list or
combo box.

When you select a value from a combo box control that already has the focus, the following events occur:

BeforeUpdate -- AfterUpdate -- Click -- Change

The Click event occurs even when you select the value using the keyboard, even though "clicking" is something most people associate
with the mouse.

Debbie

| but i dotn want it to happen after update ?? i want it to happen as soon as
| they select an answer in the CommunityGarbageDisposal combo box
|
 
in after update event of community garbage disposal combo box your code
deosnt work and gives me this error: ms access cant find the macro If
CommunityGarbageDisposal = "YES" Then
| Me

If CommunityGarbageDisposal = "YES" Then
| Me.AllowEdits = False
| Else
| Me.AllowEdits = True
| End If
|
| Exit_cmdClose_Click:
| Exit Sub
| Err_cmdClose_Click:
| MsgBox Err.Description
| Resume Exit_cmdClose_Click
|
 
Is CommunityGarbageDisposal the actual name of the combobox? If you delete CommunityGarbageDisposal and then type me. a list should
appear with the fields on your form.

Is there just one column in your combobox?

Debbie

|
| in after update event of community garbage disposal combo box your code
| deosnt work and gives me this error: ms access cant find the macro If
| CommunityGarbageDisposal = "YES" Then
|| Me
|
| If CommunityGarbageDisposal = "YES" Then
|| Me.AllowEdits = False
|| Else
|| Me.AllowEdits = True
|| End If
||
|| Exit_cmdClose_Click:
|| Exit Sub
|| Err_cmdClose_Click:
|| MsgBox Err.Description
|| Resume Exit_cmdClose_Click
||
|
|
 
Back
Top