No edits in field after filled in

B

Bonnie

Hi there. Using A02 on XP. Have a DepositForm and want to
have the field [DateDep] lock after data entry. (Edits are
allowed on a separate Supervisor form.) I have tried to
put the following in a variety of event procedures but
having trouble locking it down.

I put this in the OnGotFocus and it works initially but
after you click okay to the message, you can edit the
field. Ugh!

If Not IsNull(Me.DateDep) Then
MsgBox "This field has already been filled."
DoCmd.CancelEvent
Exit Sub
End If

Should I replace CancelEvent with Me.DateDep.Enabled=False?

Problem is that my form is a continuous form showing all
the checks received that day for processing. Don't want to
disable [DateDep] for the other records until they have
also been keyed in.

Thanks in advance for any and all help or advice!!!
 
R

Rob Oldfield

Try this in the current event of the form...

Dim Lck As Boolean
Lck = Not IsNull(Me.DateDep)
Me.DateDep.Enabled = Not Lck
Me.DateDep.Locked = Lck
 
S

Scott McDaniel

Why not simply Lock the field in the Form's Current event? Even with
continuous forms, this would function. So you'd do something like this:

Sub Form_Current()
Me.DateDep.Locked = (Nz(Me.DateDep,0) <> 0)
End Sub
 
M

Marshall Barton

Bonnie said:
Hi there. Using A02 on XP. Have a DepositForm and want to
have the field [DateDep] lock after data entry. (Edits are
allowed on a separate Supervisor form.) I have tried to
put the following in a variety of event procedures but
having trouble locking it down.

I put this in the OnGotFocus and it works initially but
after you click okay to the message, you can edit the
field. Ugh!

If Not IsNull(Me.DateDep) Then
MsgBox "This field has already been filled."
DoCmd.CancelEvent
Exit Sub
End If

Should I replace CancelEvent with Me.DateDep.Enabled=False?

Problem is that my form is a continuous form showing all
the checks received that day for processing. Don't want to
disable [DateDep] for the other records until they have
also been keyed in.

Normally, this kind of thing is done by setting the
cantrol's Loacked property in the form's Current event.

Me.DateDep.Locked = Not IsNull(Me.DateDep)

Since it's a continuous form, this will lock the text box
for all records, BUT since you can't tell if a text box is
locked by looking at it, it won't matter. As soon as you
click in a different record, the Current event fires and the
text box will be locked or unlocked as needed.
 
B

Bonnie

Hey Marsh!!! How are you? Thanks bunches for the info. It
works GREAT! Hope all is well in your part of the world. I
really appreciate your time. B
-----Original Message-----
Bonnie said:
Hi there. Using A02 on XP. Have a DepositForm and want to
have the field [DateDep] lock after data entry. (Edits are
allowed on a separate Supervisor form.) I have tried to
put the following in a variety of event procedures but
having trouble locking it down.

I put this in the OnGotFocus and it works initially but
after you click okay to the message, you can edit the
field. Ugh!

If Not IsNull(Me.DateDep) Then
MsgBox "This field has already been filled."
DoCmd.CancelEvent
Exit Sub
End If

Should I replace CancelEvent with Me.DateDep.Enabled=False?

Problem is that my form is a continuous form showing all
the checks received that day for processing. Don't want to
disable [DateDep] for the other records until they have
also been keyed in.

Normally, this kind of thing is done by setting the
cantrol's Loacked property in the form's Current event.

Me.DateDep.Locked = Not IsNull(Me.DateDep)

Since it's a continuous form, this will lock the text box
for all records, BUT since you can't tell if a text box is
locked by looking at it, it won't matter. As soon as you
click in a different record, the Current event fires and the
text box will be locked or unlocked as needed.
 
B

Bonnie

Exactly what I was asking how to do and exactly what you
answered so I'm a happy camper and grateful for your input.

Thx!
-----Original Message-----
Why not simply Lock the field in the Form's Current event? Even with
continuous forms, this would function. So you'd do something like this:

Sub Form_Current()
Me.DateDep.Locked = (Nz(Me.DateDep,0) <> 0)
End Sub
Hi there. Using A02 on XP. Have a DepositForm and want to
have the field [DateDep] lock after data entry. (Edits are
allowed on a separate Supervisor form.) I have tried to
put the following in a variety of event procedures but
having trouble locking it down.

I put this in the OnGotFocus and it works initially but
after you click okay to the message, you can edit the
field. Ugh!

If Not IsNull(Me.DateDep) Then
MsgBox "This field has already been filled."
DoCmd.CancelEvent
Exit Sub
End If

Should I replace CancelEvent with Me.DateDep.Enabled=False?

Problem is that my form is a continuous form showing all
the checks received that day for processing. Don't want to
disable [DateDep] for the other records until they have
also been keyed in.

Thanks in advance for any and all help or advice!!!


.
 
B

Bonnie

Thanks for the info!!!
-----Original Message-----
Try this in the current event of the form...

Dim Lck As Boolean
Lck = Not IsNull(Me.DateDep)
Me.DateDep.Enabled = Not Lck
Me.DateDep.Locked = Lck


Hi there. Using A02 on XP. Have a DepositForm and want to
have the field [DateDep] lock after data entry. (Edits are
allowed on a separate Supervisor form.) I have tried to
put the following in a variety of event procedures but
having trouble locking it down.

I put this in the OnGotFocus and it works initially but
after you click okay to the message, you can edit the
field. Ugh!

If Not IsNull(Me.DateDep) Then
MsgBox "This field has already been filled."
DoCmd.CancelEvent
Exit Sub
End If

Should I replace CancelEvent with Me.DateDep.Enabled=False?

Problem is that my form is a continuous form showing all
the checks received that day for processing. Don't want to
disable [DateDep] for the other records until they have
also been keyed in.

Thanks in advance for any and all help or advice!!!


.
 

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