Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update / Insert records from excel (VBA) 1

Status
Not open for further replies.

arides

IS-IT--Management
Nov 19, 2002
21
AR
Hi, weird question here.

I have a spreadsheet that uses Mic. Query for listing information.

now, this information is edited so i need to change original DBF Tables with the new values.

right now, i'm putting that information into an excel spreadsheet, and from a separate VFP program i do the final update.

But i'd like to save this step for the user... so i have 2 choices

1. run the VFP program directly from excel (i couldn't find a way... but that would be nice enough)
2. use sql update/insert from VBA to edit the tables (that i ignore if it's even possible).



I hope i'm clear, usually i'm not :D



 
Never tried this, so it may not work at all, but you can create an COM server with VFP, so in Excel you can create an instance to it and pass the INSERT/DELETE/UPDATE command to it. Here the VFP code (The Excel macro I can't write)

<VFP>

DECLARE CLASS VFPComm AS CUSTOM OLEPUBLIC
PROCEDURE RunCommand(lcCommand AS String)
TRY
&lcCommand
CATCH TO COMeRR
COMreturnerror(STR(oErr.ErrorNo) + [ Message: ] + oErr.Message ,_VFP.ServerName)
ENTRY
ENDDEFINE


and in other applciation:
oObj = CREATOBJECT("VfpCommLib.VFPComm")
oObj.RunCommand("INSERT INTO YourDBF VALUES (..)")
[/code]
something like that :eek:)


Borislav Borissov
 
Thx! that is definitively a good a idea. i'm a little short on fox knowledge (usually i work in VBA) but this gives me a good lead...


I'll try to get something directly from excel, but if I can't and i can do something interesting with this i'll post the code (AND questions... jeje)



---------------
Arides

Can God write a code so complex he couldn't understand?
 
A second option would be to use VFP's ODBC or ADO provider, then manipulate the data the same way you would Access data, or SqL Server data. (not doing much in Vb myself, I'm not sure how exactly to do this, though

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top