Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Andy Kramek
  Where is Andy Kramek?
 Hot Springs Village
 Arkansas - United States
 Andy Kramek
 To: subhankar pandey
  Where is subhankar pandey?
 Kolkata/Delhi
 India
 subhankar pandey
 Tags
Subject: RE: Create same structure to MDB file
Thread ID: 228476 Message ID: 228495 # Views: 1 # Ratings: 0
Version: Visual FoxPro 6 Category: Microsoft Office Automation
Date: Tuesday, May 19, 2009 12:34:58 PM         
   


> Hi,
>
> I'm in the process to create a table in MS-Access which suppose to be same structure VFP table. But not save the table in MS-Access. Below is my code:-
>
>
> Use MyTable in 0 Excl
> Select MyTable
> gnFieldcount = AFIELDS(gaMyArray)  && Create array
> lcPath=GETFILE('MDB', 'MDB TableName:', 'Create', 1,'Create a New File in Access')
> oAccess=CreateObject("Access.Application")
> oMDB = oAccess.NewCurrentDatabase(lcPath)
> oTable = oAccess.CurrentDb.CreateTableDef(Alias())
> FOR nCount = 1 TO gnFieldcount 
> 	lFldType=IIF(gaMyArray(nCount,2)="C",10,8 )
> 	lfldSize=IIF(gaMyArray(nCount,3)>0,gaMyArray(nCount,3),255 )
> 	loField=oTable.CreateField(gaMyArray(nCount,1), lFLDType, lFLDSize)
> 	oTable.Fields.Append(loField)
> 	oTable.Fields(gaMyArray(nCount,1)).AllowZeroLength = .T.
> ENDFOR
> oAccess.CurrentDB.TableDefs.Append(oTable)
> oAccess.CurrentDB.TableDefs.Refresh
> Release gaMyArray
> oAccess.Visible=.T.
> Store Null to oaccess,otable,oMDB
> Return
> 

> Am I missing something to save the structure in Ms-Access?
>
> Thanks in advnace.
>
> regards
> Subhankar

I don't know much about the Access object model or using Access through automation like you are trying, but I would have thought the easiest way to duplicate a VFP table in Access would be to use the GenDBC utility that ships with VFP to create the SQL Statements needed to re-create the table and then run those statements in Access to create the table.

Regards
Andy Kramek
Microsoft MVP (Visual FoxPro)
Tightline Computers Inc, Akron Ohio, USA

ENTIRE THREAD

Create same structure to MDB file Posted by subhankar pandey @ 5/19/2009 9:43:31 AM
RE: Create same structure to MDB file Posted by Andy Kramek @ 5/19/2009 12:34:58 PM
RE: Create same structure to MDB file Posted by subhankar pandey @ 5/19/2009 1:45:58 PM