Allow Edits if Field isNull

G

Guest

Hi

I have a form based upon a table [Sample Details] upon which I display
various fields. On the form, if the field [CertNo] has a value in, I want the
form to be AllowEdits=False, but this may change as the user changes the
record viewed in the form
I have put the following code in the 'On Current'event of the form but does
not appear to be working.
I am relatively new to code so code could be the problem as well as the event.
Any help greatfully received

Code

Private Sub Form_Current()
If CertNo = NotNull Then
Me.AllowEdits = False
Else
Me.AllowEdits = True
End If
End Sub
 
D

Dirk Goldgar

In
richard said:
Hi

I have a form based upon a table [Sample Details] upon which I display
various fields. On the form, if the field [CertNo] has a value in, I
want the form to be AllowEdits=False, but this may change as the user
changes the record viewed in the form
I have put the following code in the 'On Current'event of the form
but does not appear to be working.
I am relatively new to code so code could be the problem as well as
the event. Any help greatfully received

Code

Private Sub Form_Current()
If CertNo = NotNull Then
Me.AllowEdits = False
Else
Me.AllowEdits = True
End If
End Sub

If IsNull(Me!CertNo) Then
Me.AllowEdits = True
Else

Me.AllowEdits = False
End If

**or**

Me.AllowEdits = IsNull(Me!CertNo)
 
G

Guest

Hi Richard

Try the following...

Private Sub Form_Current()
If IsNull(Me.CertNo) Then
Me.AllowEdits = True
Else
Me.AllowEdits = False
End If
End Sub


(Note: I added Me. to beginning of CertNo, removed Not from If and changed
order of True and False.)

Hope this helps

Andy Hull
 
C

Carl Rapson

richard said:
Hi

I have a form based upon a table [Sample Details] upon which I display
various fields. On the form, if the field [CertNo] has a value in, I want
the
form to be AllowEdits=False, but this may change as the user changes the
record viewed in the form
I have put the following code in the 'On Current'event of the form but
does
not appear to be working.
I am relatively new to code so code could be the problem as well as the
event.
Any help greatfully received

Code

Private Sub Form_Current()
If CertNo = NotNull Then
Me.AllowEdits = False
Else
Me.AllowEdits = True
End If
End Sub

I don't think 'NotNull' is valid. Try this instead:

Me.AllowEdits = IsNull(CertNo)

Carl Rapson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top