Results 1 to 5 of 5
  1. #1
    pradeep.sands is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    49

    Question export to a 2D array

    Hi all,
    I need some information/help regarding my project. Let me explain in brief what Im looking for.


    Firstly, I have a Table
    Click image for larger version. 

Name:	Unbenannt.JPG 
Views:	27 
Size:	13.6 KB 
ID:	13184
    Now I have a form, from where I need to do the export. The export is to a ".C" file

    For this I wrote something like this:
    Code:
    Dim text As Long
    Dim path As String
    path = Application.CurrentProject.path & "\export\"
    Open (path & "\export.c") For Append As text
    Print #text, ............
    Close #text
    So, using this I export the data into a txt file (replaced with an extension .C). It works.
    Well, actually I need some help here regarding export. I need to export the data in the table as a 2D array into this C file.
    For example, I wrote something like this:
    Code:
      Print #text, "main ()" & vbCrLf _
                        ; "{ " & vbCrLf _
                        ; "int i = " & rs.Fields.Count & vbCrLf _
                        ; "int j = " & rs.RecordCount & vbCrLf _
                        ; "int Info[i][j]" & vbCrLf _
                          ....
                          ....
    Now my Info[i][j] should contain all the data from the above table.
    Ex.: considering abv table,
    Info[2][4] = { (1,aaa,ccc,xyz) , (2,bbb,ddd,xyz) }

    Can someone help me how do I realize this?

  2. #2
    TG_W is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299
    Have you tried the "DoCmd.OutputTo" method?

    Example with relevance to your needs (would need editing before your use) - DoCmd.OutputTo acOutputTable (or acOutputQuery), "Your Table or Query Name Here", acFormatTXT, "export.c"

  3. #3
    pradeep.sands is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    49
    Quote Originally Posted by TG_W View Post
    Have you tried the "DoCmd.OutputTo" method?

    Example with relevance to your needs (would need editing before your use) - DoCmd.OutputTo acOutputTable (or acOutputQuery), "Your Table or Query Name Here", acFormatTXT, "export.c"
    Hi, Thanks for your reply. "DoCmd.OutputTo" would output the entire table structure and data to the text file, which is not what I want.
    I want the following code to be in my output text file (.C file)
    Code:
     
    main()
    int i=2;
    int j=4;
    int Info[2][4]={ (1,aaa,ccc,xyz) , (2,bbb,ddd,xyz) }
    and this value of i,j are provided by the VBA using & rs.Fields.Count and & rs.RecordCount as shown in my first post and the int Info[2][4]={ (1,aaa,ccc,xyz) , (2,bbb,ddd,xyz) } should be provided by VBA by reading all records in table and then mapping to Info[i][j] but not directly hardcoding it

  4. #4
    TG_W is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299
    I think I get what you are looking to do now. Unfortunately, that is beyond where I have gone in the VBA universe. You might consider posting this thread under the "Programming" section of the forums.

  5. #5
    pradeep.sands is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    49
    Ok. I will do that. Thank you.
    And if anyone else can help me, please, waiting for your suggestions !!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 05-31-2013, 07:46 PM
  2. Would be an ARRAY statement in SAS.
    By arbnmedic in forum Access
    Replies: 2
    Last Post: 01-07-2012, 03:34 PM
  3. Array problem
    By dbdvl in forum Programming
    Replies: 6
    Last Post: 12-03-2011, 07:34 AM
  4. Array will not ReDim...
    By yeah in forum Programming
    Replies: 1
    Last Post: 10-08-2011, 06:30 PM
  5. can i put the result in array?
    By dada in forum Programming
    Replies: 1
    Last Post: 08-19-2010, 07:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums