473,396 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ODBC Call error 3146

I have an access 97 database linked to sql server..I click update on a
form
and get an error message:
Run-time error 3146 ODBC call failed

The debugger points to this line:

MyTable.Update

In this segment of code:

Private Sub Update5_Click()

Dim MyDB As Database, MyTable As Recordset, MyTmpTable As
Recordset,
Criteria As String, NewID As Long
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MyTable = MyDB.OpenRecordset("Dx5", DB_OPEN_DYNASET,
dbSeeChanges)
Set MyTmpTable = MyDB.OpenRecordset("tmp_RockDx5",
DB_OPEN_DYNASET)

MyTable.AddNew
MyTable.Update
MyTable.Move 0, MyTable.LastModified
NewID = MyTable![Dx5ID]

Me![HoldNewDxID] = NewID

If DCount("*", "Dx5Current") > 0 Then

Me![HoldOldDxID] = Me![Dx5Current].Form![Dx5ID]

'Put end date on the current
Axis 5
'record

Me![Dx5Current].Form![EndDate] = Date
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD

'Copy in data from the current
Axis 5
'record to the new record,
since it is
'likely to be similar

Set MyTable = MyDB.OpenRecordset("Dx5", DB_OPEN_DYNASET)

holdnum = Forms![DxSummary]![HoldNewDxID]
Criteria = "[Dx5ID] = " & holdnum
MyTable.FindFirst Criteria
MyTable.Edit
MyTable![CurrentGAF] = Me![Dx5Current].Form![CurrentGAF]
MyTable![HighestGAFLastYear] =
Me![Dx5Current].Form![HighestGAFLastYear]
MyTable.Update

End If

Me.Visible = False
Me![Dx5Current].Requery 'This is necessary in order to
release the
'record, so that it can be edited
if the
'user uses the Cancel button on the

add-edit
'form
Criteria = "[Dx5ID] = Forms![DxSummary]![HoldNewDxID]"

DoCmd.OpenForm "AddDx5", , , Criteria, A_EDIT

MyTmpTable.Close
MyTable.Close

Forms![AddDx5]![ClientID] = Forms![LogIn]![ActiveClient]
Forms![AddDx5]![StaffID] = Forms![LogIn]![ActiveStaff]

End Sub

Nov 13 '05 #1
2 18980
Since you are getting an ODBC error, I assume you're using linked tables. The
ODBC call failed error is the same for -any- server-side failure, and is not
terribly informative. To get the useful error information in these cases, you
must examine the Errors collection.

Looking at what you're doing, though, I'm guessing the table has one or more
required fields with no default values, so doing an Update immediately after
an AddNew is trying to create a new record without the minimum required field
data.

On 29 Mar 2005 07:00:05 -0800, "Jimbo" <ji********@motorola.com> wrote:
I have an access 97 database linked to sql server..I click update on a
form
and get an error message:
Run-time error 3146 ODBC call failed

The debugger points to this line:

MyTable.Update

In this segment of code:

Private Sub Update5_Click()

Dim MyDB As Database, MyTable As Recordset, MyTmpTable As
Recordset,
Criteria As String, NewID As Long
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MyTable = MyDB.OpenRecordset("Dx5", DB_OPEN_DYNASET,
dbSeeChanges)
Set MyTmpTable = MyDB.OpenRecordset("tmp_RockDx5",
DB_OPEN_DYNASET)

MyTable.AddNew
MyTable.Update
MyTable.Move 0, MyTable.LastModified
NewID = MyTable![Dx5ID]

Me![HoldNewDxID] = NewID

If DCount("*", "Dx5Current") > 0 Then

Me![HoldOldDxID] = Me![Dx5Current].Form![Dx5ID]

'Put end date on the current
Axis 5
'record

Me![Dx5Current].Form![EndDate] = Date
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD

'Copy in data from the current
Axis 5
'record to the new record,
since it is
'likely to be similar

Set MyTable = MyDB.OpenRecordset("Dx5", DB_OPEN_DYNASET)

holdnum = Forms![DxSummary]![HoldNewDxID]
Criteria = "[Dx5ID] = " & holdnum
MyTable.FindFirst Criteria
MyTable.Edit
MyTable![CurrentGAF] = Me![Dx5Current].Form![CurrentGAF]
MyTable![HighestGAFLastYear] =
Me![Dx5Current].Form![HighestGAFLastYear]
MyTable.Update

End If

Me.Visible = False
Me![Dx5Current].Requery 'This is necessary in order to
release the
'record, so that it can be edited
if the
'user uses the Cancel button on the

add-edit
'form
Criteria = "[Dx5ID] = Forms![DxSummary]![HoldNewDxID]"

DoCmd.OpenForm "AddDx5", , , Criteria, A_EDIT

MyTmpTable.Close
MyTable.Close

Forms![AddDx5]![ClientID] = Forms![LogIn]![ActiveClient]
Forms![AddDx5]![StaffID] = Forms![LogIn]![ActiveStaff]

End Sub


Nov 13 '05 #2
I found out the problem....it was because of an ntext field in the
table..I changed it to a varchar and it works fien now...but at least
your suggestion got me looking at the underlying table
structure...thanks

-Jim

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Vic Spainhower | last post by:
Hello, This is probably not the correct forum to post this problem but I posted it in the Access group but didn't get a reply and I'd like to move forward on this. I have setup an ODBC...
13
by: Eric E | last post by:
Two questions regarding ODBC. 1) I am connecting to a MySQL database using the following code: Function LoginToMySQL(sUsername As String, sPW As String) As Boolean Dim dbMySQL As Database Dim...
1
by: Charles | last post by:
Ok, I have an Access 97 GUI with SQL 7.0 backend. On one database I'm constantly getting a call fail. I'm not sure why. From the user accounts it seems to happen mostly when they have the form...
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
1
by: VBSponge | last post by:
Hi all. Need help here as I cant see whats wrong... I have a querydef in Access 2k which execs a stored proc in a SQL Server 2k db. I keep getting the following error, and cant stop it for the...
1
by: Doolittle | last post by:
Hi, I'm a relatively new VBA programmer but have been given the task of repairing a database that currently appears with "3146 ODBC--call failed." This happens when various criteria are input into...
9
by: Greg Strong | last post by:
Hello All, What is the maximum length of an ODBC pass through query? Things work fine with the code except when I try to create a view which is pretty complex in Oracle. I'm using a DSN...
0
by: hello_2you | last post by:
Hello, I have a vb program that connects to odbc to an sqlexpress server. When i try to write data to the db, i get this message: Release Error: Script #1 (Ascent Capture Database) "de...
16
by: network-admin | last post by:
We have Problems with Access query on Oracle 10g Database with ODBC Connection. The Query_1 is such as select * from xtable where ycolumn <"S" Result = ODBC Faild...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.