View Full Version : VBA Lock Textbox


shamas21
07-10-2008, 05:24 AM
Hi All

I have a bound OLEAttatchment in my Form.

Im trying to unlock it then add a file then lock it again.

The lock will not execute.

Can someone help?


Private Sub btnattach_Click()

On Error Resume Next

Dim sFile As String

With Application.FileDialog(msoFileDialogOpen)
.Show
With .SelectedItems
sFile = .Item(1)

End With
End With

' This is where it doesnt lock
With Me.oleAttatachments
.SetFocus
.Locked = False
.SourceDoc = sFile
.Action = acOLECreateEmbed
.SizeToFit
.Enabled = False
.Locked = True
End With

End Sub

boblarson
07-12-2008, 07:16 PM
You have to save the record first before relocking.

Do this:

With Me.oleAttatachments
.SetFocus
.Locked = False
.SourceDoc = sFile
.Action = acOLECreateEmbed
.SizeToFit
If Me.Dirty Then Me.Dirty = False
.Enabled = False
.Locked = True
End With