Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RE: 7013.7 Update record from VB

4 views
Skip to first unread message

mimer

unread,
Sep 3, 2010, 9:49:03 AM9/3/10
to
Hi!

I have tried almost the same code but with no success:

Public gAx As AxaptaCOMConnector.Axapta3
Public gAxTable As AxaptaCOMConnector.IaxaptaRecord

Set gAxTable = gAx.CreateRecord(sTable)

While Cells(i, 1) <> ""
gAx.TTSBegin
gAxTable.InitValue

gAxTable.field(vNames(1, j)) = sValue
gAx.ExecuteStmt "select forupdate * from %1 where %1.ItemId == '" &
gAxTable.field(vNames(1, 2)) & "'", gAxTable

gAxTable.Update

gAx.TTSCommit

If Not gAxTable.Found Then
gAx.TTSAbort
MsgBox "Nyckeln '" & gAxTable.field(vNames(1, 2)) & "' hittades
inte. Processen avbruten!", vbCritical, "Felhantering."
GoTo exit_import
End If

i = i + 1
Wend

Code is running perfectly but nothing happens in database....

One strange thing is that I need the star, *, after FORUPDATE - otherwise I
get a running error that says "unable to compile...." and also it states that
gAxTable is not found (seen in the expanded ExecuteStmt string).

Would be VERY greatful for a hint or solution!

BR/
jonas

"HTO" wrote:

> I would be best pratice if your MsgBox were after the commit!
>
> Axapta.ttsbegin
> CustTable.ExecuteStmt "select forupdate %1 where %1.AccountNum == '9999'"
> If CustTable.Found Then
>
> CustTable.field("Name") = "test"
> CustTable.Update
>
> End If
> Axapta.ttscommit
>
> if not CustTable.Found Then
> MsgBox "Cant find record"
> end if
>
> technet.navision.com Posting date: Thursday, May 08, 2003
>
> technet.navision.com Posting path: Navision Axapta/Technology (Ax)/Axapta COM Connector

0 new messages