Hello Everyone
I have a main form (frmNewOrder) and a sub form (SubOrderBenefi ciary).
On the main form I have a button which sends the Subform
(SubOrderBenefi ciary) to a newrecord. Everything works fine expect that
when I press the button, the controls on the subform display an #Error
for a fraction of a second when changing from the current record on the
subform to the new record and theneverything works fine.
Does anyone knows how can I prevent this as it does not look
professional?
The code Im using is as follows:
Private Sub cmdNewBene_Clic k()
On Error GoTo Err_cmdNewBene_ Click
Dim cn As ADODB.Connectio n
Dim rs As ADODB.Recordset
Set cn = CurrentProject. AccessConnectio n
Set rs = New ADODB.Recordset
Set SubBen = Me.SubOrderBene ficiary.Form
With rs
Set .ActiveConnecti on = cn
.Source = "SELECT * FROM tblBeneficiary WHERE BeneficiaryID =
''"
.LockType = adLockOptimisti c
.CursorType = adOpenKeyset
.Open
End With
Set SubBen.Recordse t = rs
Set rs = Nothing
Set cn = Nothing
Me.SubOrderBene ficiary.SetFocu s
Exit_cmdNewBene _Click:
Exit Sub
Err_cmdNewBene_ Click:
MsgBox "Your request could not be processed. Err 14 - " &
Err.Description & Err.Number, vbCritical, "Error"
Resume Exit_cmdNewBene _Click
End Sub
Any comments and possible solution would help me a lot.
Thanks in advanced.
GAVO.