harmankardon
Registered User.
- Local time
- Yesterday, 20:38
- Joined
- Aug 8, 2011
- Messages
- 71
Hello all,
I have a button in the header of a subform that when clicked brings up an insert file dialog for users to attach BLOBs to a form using an OLE field as the container.
The problem I am having is tricky. If there are no records in the subform, and I've just opened the parent form, I can click my new attachment button without any problems. But if I add 1 attachment, delete it (so now the subform has 0 records) and then try to click new attachment again I get a "No current record" error, but it doesn't seem to have any affect on anything. I just click OK and it continues on as expected. The same thing happens too when I try to go into design view after adding, deleting and re-adding an attachment.
I can't even seem to trap this error by putting a break point on my first line of code, the error happens before the first line executes.
The code I am using looks like this:
Any ideas? Is there some kind of button down event that could be firing before button click?
I have a button in the header of a subform that when clicked brings up an insert file dialog for users to attach BLOBs to a form using an OLE field as the container.
The problem I am having is tricky. If there are no records in the subform, and I've just opened the parent form, I can click my new attachment button without any problems. But if I add 1 attachment, delete it (so now the subform has 0 records) and then try to click new attachment again I get a "No current record" error, but it doesn't seem to have any affect on anything. I just click OK and it continues on as expected. The same thing happens too when I try to go into design view after adding, deleting and re-adding an attachment.
I can't even seem to trap this error by putting a break point on my first line of code, the error happens before the first line executes.
The code I am using looks like this:
Code:
Private Sub btnNewRecord_Click()
Dim BytesRead As Variant, BytesWritten As Variant
Dim Msg As String
Dim T As Recordset
Dim source As String
' Open the BLOB table.
Me.AllowAdditions = True
Set T = Me.Recordset
T.AddNew
T.Fields("REA_NUM") = Me.Parent.Form.REA_Num
' Move file into record.
source = modBLOB.getOpenFileName()
If source <> "" Then
BytesRead = ReadBLOB(source, T, "Blob")
If (BytesRead < 0) Then
MsgBox "Error Saving attachment", vbCritical + vbOKOnly, "Error"
End If
T.Update
Else
T.CancelUpdate
End If
Me.AllowAdditions = False
End Sub
Any ideas? Is there some kind of button down event that could be firing before button click?