Link to home
Start Free TrialLog in
Avatar of saichak
saichak

asked on

.Update fails

Dear Expert,

Please  find the code below.

************************************
Function Acclev(prmMain)
Dim Accset As Recordset
Dim ctl As Control

Dim AccMatch As Boolean
AccMatch = False

Set Accset = Datadb.OpenRecordset("TBL-MENUS", dbOpenDynaset)
' Accset.Index = "PrimaryKey"      '******OMWB********
Me.subOptions.Form!Titl.SetFocus
For Each ctl In Me.subOptions.Form
  If ctl.ControlType = acCommandButton Then
    With Accset
   '   .Seek "=", prmMain, ctl.Name  '******OMWB********
      Do While Not .EOF  '******OMWB********
      .MoveNext  '******OMWB********
      If Not .EOF Then
        If .Fields("mainopt") = prmMain And .Fields("subopt") = ctl.Name Then  '******OMWB********
            AccMatch = True '******OMWB********
            Exit Do
            'Exit Do '******OMWB********
        End If '******OMWB********
      End If
      Loop '******OMWB********
     
      If Not AccMatch Then '******OMWB********
        .AddNew
        !mAINOPT = prmMain
        !SubOpt = ctl.Name
        .Update
        .Bookmark = .LastModified
      End If
      If !Access > SECLEV Then
        ctl.Enabled = False
        ctl.ForeColor = MyGrey
      Else
        ctl.Enabled = True
        ctl.ForeColor = MyBlack
      End If
    End With
  End If
Next
Accset.Close
Set Accset = Nothing 'ge
If SECLEV < 99 Then
  Me.subOptions.Form.ShortcutMenuBar = ""
End If
End Function

********************************************

TBL-MENUS is a access query that pulls data from ODBC link table(from oracle ). The update procedure fails  with the error code '3146' "ODBC -- call failed".

Could you please help . This is a really urgent one.

Thanks & regards,
SC
ASKER CERTIFIED SOLUTION
Avatar of nico5038
nico5038
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of saichak
saichak

ASKER

Dear Expert,

I have checked it. Neither mandatory field nor the foreign key constraint.

ANy other Hint please!!

Regards,
SC
Avatar of saichak

ASKER

Thanks Nic.

The problem was actually very simple. On investigation it was found that duplicate records were going to be inserted i.e. primary key violation has been in place.

Many thanks for you help again.

SC
Glad it worked out, they are often "nasty" to trace in a .update setting.
Thus for debugging I prefer the SQL query as that has the possibility to use the query editor to simulate the query.

Success !

Nic;o)