Group:  Microsoft Access ยป microsoft.public.access.odbcclientsvr
Thread: Problem adding new record to ODBC linked table

Geek News

Problem adding new record to ODBC linked table
"SF" <xyz[ at ]online.com.kh> 6/14/2007 4:55:51 AM
Hi,

I have just recently moving my back end to SQL Server 2005 and reconnecting
my table through ODBC. I have got an error trying to insert new record.

First I got an error message told me to change from dnOpendynaset to
dbSeeChanges
when I ... I got error 3001 - Invalid agument
I use Office 2003, Windows XP

Private Sub Option1_Click()
On Error GoTo Err_Option1_Click:

Dim wsp As Workspace
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim ctl As Control

Set wsp = DBEngine.Workspaces(0)
wsp.BeginTrans


DoCmd.Hourglass True
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblContacts", dbSeeChanges)

With rst
.AddNew
![Co_OrgID] = Me.Co_OrgID
![Co_Title_eID] = Me.Co_Title_eID
![Co_FirstName_e] = Me.Co_FirstName_e
![Co_FirstName_k] = Me.Co_FirstName_k
![Co_LastName_e] = Me.Co_LastName_e
![Co_LastName_k] = Me.Co_LastName_k
![Co_PositionID] = Me.Co_PositionID
![Co_Address1_e] = Me.Co_Address1_e
![Co_DistrictID] = Me.Co_DistrictID
![Co_CommuneID] = Me.Co_CommuneID
![Co_VillageID] = Me.Co_VillageID
![Co_Province_ID] = Me.Co_Province_ID
![Co_ReligionID] = 1 ' Me.Co_ReligionID
![Co_PartyID] = 1 ' Me.Co_PartyID
![Co_Education] = Me.Co_Education
![Co_Age] = Me.Co_Age
![Co_Telephone] = Me.Co_Telephone
![Co_Fax] = Me.Co_Fax
![Co_EMail] = Me.Co_EMail
'![Co_WebSite] = Me.co_
![Owner] = CurrentUser()
![DateUpdate] = Now()
![CreatedBy] = CurrentUser()
![DateCreated] = Now()
'![ObjectID] = 8
![Pc_Name] = ComputerName()
.Update
End With

rst.Close
wsp.CommitTrans
DoCmd.Hourglass False

DoCmd.Close

Exit_Option1_Click:
Exit Sub

Err_Option1_Click:
'ErrorLogs(err.Number, err.Description, me.Name, ComputerName)


MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbInformation
Resume Exit_Option1_Click

End Sub


Re: Problem adding new record to ODBC linked table
Stefan Hoffmann <stefan.hoffmann[ at ]explido.de> 6/14/2007 8:54:40 AM
hi,

SF wrote:
[Quoted Text]
> I have just recently moving my back end to SQL Server 2005 and reconnecting
> my table through ODBC. I have got an error trying to insert new record.
First of all, check whether your tables have primary keys or not. Then
add a field of SQL Server data type TIMESTAMP to each table on the server.

Relink your tables. Check in design view, if Jet has recognized the
primary keys.

Add a record manually to this linked table.

Disable the error handler, in which line of your code does the debugger
halt execution?


mfG
--> stefan <--
Re: Problem adding new record to ODBC linked table
"SF" <xyz[ at ]online.com.kh> 6/15/2007 12:31:18 AM
Hi Stefan

Appreciate your prompt advice.

My tables have primary key as well as the timestamp. I still got error
Invalid argument. (Error 3001)
at set rst = dbs.openrecordset("MyTable", dbseechanges)
I can however add record to the table itself manually.

SF


"Stefan Hoffmann" <stefan.hoffmann[ at ]explido.de> wrote in message
news:%23LPFnGmrHHA.500[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
> hi,
>
> SF wrote:
>> I have just recently moving my back end to SQL Server 2005 and
>> reconnecting my table through ODBC. I have got an error trying to insert
>> new record.
> First of all, check whether your tables have primary keys or not. Then add
> a field of SQL Server data type TIMESTAMP to each table on the server.
>
> Relink your tables. Check in design view, if Jet has recognized the
> primary keys.
>
> Add a record manually to this linked table.
>
> Disable the error handler, in which line of your code does the debugger
> halt execution?
>
>
> mfG
> --> stefan <--


Re: Problem adding new record to ODBC linked table
"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)> 6/19/2007 6:16:42 AM
You don't replace dnOpendynaset with dbSeeChanges but instead, you add
dbSeeChanges as the third parameter:

set rst = dbs.openrecordset("MyTable", dnOpendynaset, dbSeeChanges)

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)


"SF" <xyz[ at ]online.com.kh> wrote in message
news:euLQSQurHHA.2384[ at ]TK2MSFTNGP06.phx.gbl...
[Quoted Text]
> Hi Stefan
>
> Appreciate your prompt advice.
>
> My tables have primary key as well as the timestamp. I still got error
> Invalid argument. (Error 3001)
> at set rst = dbs.openrecordset("MyTable", dbseechanges)
> I can however add record to the table itself manually.
>
> SF
>
>
> "Stefan Hoffmann" <stefan.hoffmann[ at ]explido.de> wrote in message
> news:%23LPFnGmrHHA.500[ at ]TK2MSFTNGP02.phx.gbl...
>> hi,
>>
>> SF wrote:
>>> I have just recently moving my back end to SQL Server 2005 and
>>> reconnecting my table through ODBC. I have got an error trying to insert
>>> new record.
>> First of all, check whether your tables have primary keys or not. Then
>> add a field of SQL Server data type TIMESTAMP to each table on the
>> server.
>>
>> Relink your tables. Check in design view, if Jet has recognized the
>> primary keys.
>>
>> Add a record manually to this linked table.
>>
>> Disable the error handler, in which line of your code does the debugger
>> halt execution?
>>
>>
>> mfG
>> --> stefan <--
>
>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net