Fields Locked

G

Guest

I have some code behind a forms On Current event.

Private Sub Form_Current()

'Set Locked property based on whether user is entering a new record
Dim fLocked As Boolean
fLocked = Not Me.NewRecord
[CLIENT_NUMBER].Locked = fLocked
[Client_Name].Locked = fLocked
End Sub

If the client_Number and Client_Name fields are filled in (not a new record)
I would like those fields locked (not able to overwrite). If the record is
not new and those fields are NOT filled in, I would like those fields to be
unlocked also - just like if the record was new. I don't know how to adjust
the code to handle this. A person can fill in some of the form fields and
come back later to fill in the Client_Number or Client_Name. I need help.
 
R

Rick Brandt

LLoraine said:
I have some code behind a forms On Current event.

Private Sub Form_Current()

'Set Locked property based on whether user is entering a new record
Dim fLocked As Boolean
fLocked = Not Me.NewRecord
[CLIENT_NUMBER].Locked = fLocked
[Client_Name].Locked = fLocked
End Sub

If the client_Number and Client_Name fields are filled in (not a new
record) I would like those fields locked (not able to overwrite). If
the record is not new and those fields are NOT filled in, I would
like those fields to be unlocked also - just like if the record was
new. I don't know how to adjust the code to handle this. A person
can fill in some of the form fields and come back later to fill in
the Client_Number or Client_Name. I need help.

Instead of testing for NewRecord use the IsNull() function to see if the
fields are filled in or not.
 
G

Guest

I am sorry but I am VBA challenged. Can you show me how to revise the code
to use Is Null()

Rick Brandt said:
LLoraine said:
I have some code behind a forms On Current event.

Private Sub Form_Current()

'Set Locked property based on whether user is entering a new record
Dim fLocked As Boolean
fLocked = Not Me.NewRecord
[CLIENT_NUMBER].Locked = fLocked
[Client_Name].Locked = fLocked
End Sub

If the client_Number and Client_Name fields are filled in (not a new
record) I would like those fields locked (not able to overwrite). If
the record is not new and those fields are NOT filled in, I would
like those fields to be unlocked also - just like if the record was
new. I don't know how to adjust the code to handle this. A person
can fill in some of the form fields and come back later to fill in
the Client_Number or Client_Name. I need help.

Instead of testing for NewRecord use the IsNull() function to see if the
fields are filled in or not.
 
R

Rick Brandt

LLoraine said:
I am sorry but I am VBA challenged. Can you show me how to revise
the code to use Is Null()

Me![CLIENT_NUMBER].Locked = Not IsNull(Me![CLIENT_NUMBER])
Me![Client_Name].Locked = Not IsNull(Me![Client_Name])
 
G

Guest

Thank you - that seems to work.

Rick Brandt said:
LLoraine said:
I am sorry but I am VBA challenged. Can you show me how to revise
the code to use Is Null()

Me![CLIENT_NUMBER].Locked = Not IsNull(Me![CLIENT_NUMBER])
Me![Client_Name].Locked = Not IsNull(Me![Client_Name])
 

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

Similar Threads


Top