VBA Lock Textbox

shamas21

Registered User.
Local time
Today, 19:32
Joined
May 27, 2008
Messages
162
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?

Code:
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
 
Last edited:
You have to save the record first before relocking.

Do this:
Code:
With Me.oleAttatachments
.SetFocus
.Locked = False
.SourceDoc = sFile
.Action = acOLECreateEmbed
.SizeToFit
[color=red]If Me.Dirty Then Me.Dirty = False[/color]
.Enabled = False
.Locked = True
End With
 

Users who are viewing this thread

Back
Top Bottom