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.Se tFocus
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.Shortcu tMenuBar = ""
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
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-
' Accset.Index = "PrimaryKey" '******OMWB********
Me.subOptions.Form!Titl.Se
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.Shortcu
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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)
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)
ASKER
I have checked it. Neither mandatory field nor the foreign key constraint.
ANy other Hint please!!
Regards,
SC