oncurrent problem

mboe

Registered User.
Local time
Today, 16:23
Joined
Dec 27, 2000
Messages
51
I have a one to many relationship between a customers table and a servers table. I have a customer form with a server subform. I added a oncurrent event procedure to the servers subform. It seems for some reason the oncurrent code I have or any on current code causes a problem when I delete the customer (with cascading delete). It says unable to update record locked. If I remove the oncurrent event I do not have the problem. Any ideas.

Here is the code:

Private Sub Form_Current()
If ([domain controller].Value = True) Then
optOBDC.Enabled = True
optOPDC.Enabled = True
End If
If ([domain controller] = False) Then
optOBDC.Enabled = False
optOBDC.Value = False
optOPDC.Enabled = False
optOPDC.Value = False
End If
If Me.NewRecord Then
Me.lblRecordNumber.Caption = "New"
Else
Me.lblRecordNumber.Caption = Me.CurrentRecord
End If
End Sub
 
I hate using bandaids like this, but if you don't mind them, you can give it a shot.

Dimension a boolean variable with scope for the form. After the "Option Explicit" line
Dim flgDelete as boolean

Form_Open()
flgDelete=False

CmdDelete_Click()
flgDelete=True
your code here
flgDelete=false

Form_Current()
if flgDelete=false then
If ([domain controller].Value = True) Then
optOBDC.Enabled = True
optOPDC.Enabled = True
End If
If ([domain controller] = False) Then
optOBDC.Enabled = False
optOBDC.Value = False
optOPDC.Enabled = False
optOPDC.Value = False
End If
If Me.NewRecord Then
Me.lblRecordNumber.Caption = "New"
Else
Me.lblRecordNumber.Caption = Me.CurrentRecord
End If
Endif

What this does is when you click the Delete button, it sets the flag to true. Then your onCurrent code will only run if the Delete button hasn't been clicked. It's important to set the Delete flag back to False after you delete the record.
 

Users who are viewing this thread

Back
Top Bottom