Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

One Field two different data strings

Discussion in 'Information Technology' started by shinde.shailesh@gmail.com, Jul 28, 2006.

  1. shinde.shailesh@gmail.com

    shinde.shailesh@gmail.com
    Expand Collapse
    Guest

    Hi All,

    I am runnning Macro with Passolo.
    I have to .mdb file with Table name "lemmas" and one field "lemma".

    Here I want to put data from Passolo translist into "lemma" this list
    contains source string and traget string, source string means data in
    english language and target string means data in german/localized
    language.

    For the same i have done with Storing data in Excel and trying to do
    the same in MS Access.

    EXCEL:
    Below is the code and output.

    Sub Main
    'Get a translation list
    Dim trn As PslTransList
    Dim srn As PslSourceList
    Set trn = PSL.ActiveProject.TransLists(1)

    If trn Is Nothing Then Exit Sub


    'Open Excel And create a workbook
    Dim ex As Object
    Set ex = CreateObject("Excel.Application")
    Dim wb As Object
    Set wb = ex.Workbooks.Add
    'Set wb = ex.ActiveWorkBook
    Dim j As Long
    Dim i As Long
    For i = 1 To trn.StringCount
    j = 2*i
    With wb.ActiveSheet
    .Range("a" & CStr(j - 1)) = trn.String(i).SourceText
    .Range("a" & CStr(j)) = trn.String(i).Text
    End With
    Next i
    ex.Quit

    End Sub

    And Output :

    Column A
    Invalid Currency. (Source string)
    Ungültige Währung. (Target string)
    Invalid DateTime.
    Ungültiges Datum oder ungültige Zeit.
    Invalid DateTimeSpan.
    Ungültige Datums- oder Zeitspanne.
    Invalid filename.
    Ungültiger Dateiname.
    Failed to open document.
    Fehler beim Öffnen des Dokuments.
    Failed to save document.
    Fehler beim Speichern des Dokuments.


    So the same output i need in Access, means source string in one row and
    in next row target string. In one field (lemma) source and target
    strings.

    For the same I have done like:

    Sub Main
    ' Get a translation list
    Dim trn As PslTransList
    Set trn = PSL.ActiveProject.TransLists(1)
    If trn Is Nothing Then Exit Sub

    Dim x As Long
    Dim Db1 As DAO.Database
    Dim Rs1 As DAO.Recordset

    Set Db1 = DBEngine.OpenDatabase("access_schema.mdb")
    Set Rs1 = Db1.OpenRecordset("Lemmas",dbOpenTable)

    For x = 1 To trn.StringCount
    With Rs1
    ..AddNew
    ..Fields("Lemma") = trn.String(x).SourceText 'Adding source strings to
    Database
    '.Fields("Lemma") = trn.String(x).Text 'Adding Target
    strings to Database
    ..Update

    End With
    Next

    Db1.Close

    End Sub

    With this code I can able to store source string in field "lemma" but
    can able to store target string in next row of field "lemma"

    Can anyone help with this?

    Thanks,
    Shailesh
     
  2. Loading...


  3. Larry Linson

    Larry Linson
    Expand Collapse
    Guest

    Access is not "Excel on steroids" just allowing more data storage.

    You appear to make the assumption that the records in Access Tables are
    "ordered" as are cells in Excel, but records in relational database tables
    are, by definition, unordered. The fact that you enter the two text strings
    one after the other does not assure their location in the Table. To see the
    records from an Access Table in a particular order, you need to retrieve
    them with a Query which specifies the Field(s) on which to sort (or, in
    other words, a Query whose SQL includes an ORDER BY clause).

    You need two Fields in the Records, and, possibly, for performance another
    to serve as a key field.

    Larry Linson

    <shinde.shailesh@gmail.com> wrote in message
    news:1152012819.405070.129220@h44g2000cwa.googlegroups.com...
    Hi All,

    I am runnning Macro with Passolo.
    I have to .mdb file with Table name "lemmas" and one field "lemma".

    Here I want to put data from Passolo translist into "lemma" this list
    contains source string and traget string, source string means data in
    english language and target string means data in german/localized
    language.

    For the same i have done with Storing data in Excel and trying to do
    the same in MS Access.

    EXCEL:
    Below is the code and output.

    Sub Main
    'Get a translation list
    Dim trn As PslTransList
    Dim srn As PslSourceList
    Set trn = PSL.ActiveProject.TransLists(1)

    If trn Is Nothing Then Exit Sub


    'Open Excel And create a workbook
    Dim ex As Object
    Set ex = CreateObject("Excel.Application")
    Dim wb As Object
    Set wb = ex.Workbooks.Add
    'Set wb = ex.ActiveWorkBook
    Dim j As Long
    Dim i As Long
    For i = 1 To trn.StringCount
    j = 2*i
    With wb.ActiveSheet
    .Range("a" & CStr(j - 1)) = trn.String(i).SourceText
    .Range("a" & CStr(j)) = trn.String(i).Text
    End With
    Next i
    ex.Quit

    End Sub

    And Output :

    Column A
    Invalid Currency. (Source string)
    Ungültige Währung. (Target string)
    Invalid DateTime.
    Ungültiges Datum oder ungültige Zeit.
    Invalid DateTimeSpan.
    Ungültige Datums- oder Zeitspanne.
    Invalid filename.
    Ungültiger Dateiname.
    Failed to open document.
    Fehler beim Öffnen des Dokuments.
    Failed to save document.
    Fehler beim Speichern des Dokuments.


    So the same output i need in Access, means source string in one row and
    in next row target string. In one field (lemma) source and target
    strings.

    For the same I have done like:

    Sub Main
    ' Get a translation list
    Dim trn As PslTransList
    Set trn = PSL.ActiveProject.TransLists(1)
    If trn Is Nothing Then Exit Sub

    Dim x As Long
    Dim Db1 As DAO.Database
    Dim Rs1 As DAO.Recordset

    Set Db1 = DBEngine.OpenDatabase("access_schema.mdb")
    Set Rs1 = Db1.OpenRecordset("Lemmas",dbOpenTable)

    For x = 1 To trn.StringCount
    With Rs1
    ..AddNew
    ..Fields("Lemma") = trn.String(x).SourceText 'Adding source strings to
    Database
    '.Fields("Lemma") = trn.String(x).Text 'Adding Target
    strings to Database
    ..Update

    End With
    Next

    Db1.Close

    End Sub

    With this code I can able to store source string in field "lemma" but
    can able to store target string in next row of field "lemma"

    Can anyone help with this?

    Thanks,
    Shailesh
     

Share This Page