Lock/Un-Lock Field

G

Guest

Hello again....I have a code that when a form is opened it copies data from
one field and pastes into another field. The problem is I need the field the
funtion is copying data into to remain locked. However, if the field is
locked the copy function does not work.

I need this funtion to be able to unlock the field, then copy the data into
the field and lock the field back up again. Any suggestions will of course be
greatly appreciated.

Here is my code so far:

Function LastModified_CopyFuntion()
On Error GoTo LastModified_CopyFuntion_Err
DoCmd.GoToControl "DateModified2"
DoCmd.RunCommand acCmdCopy
DoCmd.GoToControl "History2"
SendKeys "{Right}", True
SendKeys "{Enter}", True
DoCmd.RunCommand acCmdPaste
SendKeys "{Tab}", True

LastModified_CopyFuntion_Exit:
Exit Function

LastModified_CopyFuntion_Err:
MsgBox Error$
Resume LastModified_CopyFuntion_Exit

End Function
 
S

Scott McDaniel

Randy said:
Hello again....I have a code that when a form is opened it copies data
from
one field and pastes into another field. The problem is I need the field
the
funtion is copying data into to remain locked. However, if the field is
locked the copy function does not work.

I need this funtion to be able to unlock the field, then copy the data
into
the field and lock the field back up again. Any suggestions will of course
be
greatly appreciated.

You can copy data much more easily:

me.History2 = Me.DateModified
 
G

Guest

Thanks Scott for your suggestion. I did try it, however, doing this way
causes the existing data in that field to be overwritten or wipped out. I
need to be able to retain the existing data in that field in addition to
adding more data. The way I have it it sends the cursor to the end of the
field and then copies the data into the field preserving the existing data
within that field. If there is a better way of doing that please let me know.
I could set the keyboard to automatically go to the end of the field but that
is a global setting and messes up the rest of my forms.
 

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