[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

.Update fails

Posted on 2006-03-21
4
Medium Priority
?
243 Views
Last Modified: 2008-03-06
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
0
Comment
Question by:saichak
  • 2
  • 2
4 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 1500 total points
ID: 16245217
Make sure that the mandatory fields in the table are filled and also check the foreign keys to exist.

Nic;o)
0
 

Author Comment

by:saichak
ID: 16245484
Dear Expert,

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

ANy other Hint please!!

Regards,
SC
0
 

Author Comment

by:saichak
ID: 16245957
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
0
 
LVL 54

Expert Comment

by:nico5038
ID: 16246026
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)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question