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

Sir,
Thanks for suggestion.I'll play to resolve this issue with GenDBC utility also.However, My above code was problem because the way I come out from access automation was wrong somehow, .i.e.
oAccess.Visible=.T.
oAccess.DoCmd.Close && Proper close &&
oAccess.Quit()	 && after close comeout from auotomation&& 
Store Null to oAccess,otable,oMDB,loField
Return

Now I got the table in Access finaly.
Since this is my first attempt to play with Ms-Access
I'dont say the above code is best and perfect.

regards
Subhankar

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