vba unable to replace dbf via apollo engine

vba unable to replace dbf via apollo engine

Postby ROBERTCHENTPE » Wed Feb 09, 2011 12:45 pm

Dear Sir,

I use VBA to access dbf data via apollo engine. I am unable to replace dbf to the record appended successed.

Anyone, please kindly teach/help me to correct the code as hereunder and kindly tell where I can find the sample code for reference for VBA.

"Quoted"
declare Sub sx_Replace Lib "SDE7.DLL" (ByVal cpFieldName As String, ByVal iDataType As Integer, vpData As Any)
Public M_MAWB, M_HAWB As String

''iDataType: The type of data represented by vpData. It must be one of the following defined constants:
' R_CHAR Character (0-255 bytes long)

Sub APOLOTEST22()
'Using Apollo COM with Visual Basic

Dim oTable As Object
' Local data access
Set oTable = CreateObject("ApolloCOM7.Table")
oTable.AccessMethod = "amLocal"
oTable.DatabaseName = "C:\Apollo\Data\"
' oTable.TableName = "TEST.dbf"
oTable.TableName = "WBIL.dbf"
'The next line code error in Excel VBA
'oTable.Exclusive = True  ''use open in exclusive mode to index
oTable.Open ''' 'It will be error fail when the dbf file is no valid record at all (* marked is not valid record)
oTable.AppendBlank
m_recno = oTable.RecNo
oTable.RLock (m_recno)
If oTable.Locked(m_recno) Then
M_MAWB = "mb"
M_HAWB = "hb"

'' I have problems to replace the concerning data to dbf file
'' oTable.sx_Replace(MAWB, M_MAWB)
oTable.sx_Replace "MAWB", R_CHAR, ByVal RTrim$((M_MAWB))
oTable.sx_Replace "HAWB", R_CHAR, ByVal RTrim$((M_HAWB))

oTable.Unlock (m_recno)
End If

oTable.Close
Set oTable = Nothing
End Sub
ROBERTCHENTPE
 
Posts: 1
Joined: Wed Feb 09, 2011 2:29 am

Return to FiveWin for CA-Clipper

Who is online

Users browsing this forum: No registered users and 5 guests