The import works but lots of blank records are created in the process. I'm not sure why. I also figure there must be a more effective way to do what I am trying to do. This is a import routine called by a button in a form.
Code:
imdata = GETFILE("xls")
filpth = trim(imdata)
***********************************************************************
* Do the following process only if a file is selected *
* If cancel is selected than this process is skipped *
***********************************************************************
if len(filpth) > 1 THEN
thisform.Pageframe1.page2.text3.Value = filpth
SET EXCLUSIVE ON
SET SAFETY OFF
**** Empty imptemp ***
SELECT imptemp
ZAP
*********************************************************************
* Progress bar to make it look cool *
*********************************************************************
thisform.Pageframe1.page2.Text4.value = "Importing Spreadsheet"
thisform.Pageframe1.Page2.Olecontrol1.Visible = .t.
For I = 1 TO 25
for x= 1 to 40000
next x
Thisform.Pageframe1.Page2.Olecontrol1.value = ((I*100)/100)
x=0
Next I
*********************************************************************
* Import Spreadsheet *
*********************************************************************
append from &filpth TYPE XL8 SHEET "6A MACD List"
**** The first record in the imported file is the field names **
**** so it needs to be deleted **
GO top
DELETE record 1
PACK
*********************************************************************
* Need to place the job imformation into the jobs table *
*********************************************************************
SELECT jobs
APPEND BLANK
replace projname WITH TRIM(imptemp.customer)
replace address WITH TRIM(imptemp.address)
replace city WITH TRIM(imptemp.city)
replace zip WITH TRIM(imptemp.zip)
replace state WITH TRIM(imptemp.st)
*********************************************************************
* Sort imptemp to temp2 and erase the records and put *
* the sorted records back into imptemp and delete temp2 *
*********************************************************************
SELECT imptemp
SORT TO temp2 ON dispositio, xsm_site_n
ZAP
APPEND from temp2
ERASE temp2
*********************************************************************
* For each record in imptemp create a record in disposition *
*********************************************************************
FOR b= 1 TO RECCOUNT()
GOTO RECORD b
*******************************************************************
* Part of the progress bar *
*******************************************************************
thisform.pageframe1.page2.text4.Value = "Importing Record "+STR(RECNO())
SELECT dispositions
APPEND BLANK
replace projname WITH TRIM(imptemp.customer)
replace xsmsite WITH TRIM(imptemp.xsm_site_n)
replace disposition WITH TRIM(imptemp.dispositio)
DO CASE
CASE TRIM(disposition) = "Add"
replace finalstatus WITH "Pending"
CASE TRIM(disposition) = "Out of scope"
replace finalstatus WITH "NA"
CASE TRIM(disposition) = "Move"
replace finalstatus WITH "Pending"
CASE TRIM(disposition) = "Remove-Regency"
replace finalstatus WITH "Pending"
CASE TRIM(disposition) = "Remove-Depot"
replace finalstatus WITH "Pending"
CASE TRIM(disposition) = "Remove-Donate"
replace finalstatus WITH "Pending"
CASE TRIM(disposition) = "Unchanged"
replace finalstatus WITH "Pending"
ENDCASE
replace disdate WITH TRIM(imptemp.dispositi1)
replace assetno WITH TRIM(imptemp.asset_numb)
replace manufacturer WITH TRIM(imptemp.manufactur)
replace model WITH TRIM(imptemp.model)
replace serialno WITH TRIM(imptemp.serial_num)
replace orgdept WITH TRIM(imptemp.org___dept)
replace movefrom WITH TRIM(imptemp.move_from_)
replace roomcube WITH TRIM(imptemp.room___cub)
replace meterreading WITH TRIM(imptemp.meter_read)
replace contact1name WITH TRIM(imptemp.contact_na)
replace contact1number WITH TRIM(imptemp.contact_ph)
replace contact1email WITH TRIM(imptemp.contact_e_)
replace comments WITH TRIM(imptemp.comment)
replace faxan WITH TRIM(imptemp.fax__analo)
replace rightfax WITH TRIM(imptemp.fax_number)
replace ipaddress WITH TRIM(imptemp.ip_address)
replace gateway WITH TRIM(imptemp.gateway)
replace subnet WITH TRIM(imptemp.subnet)
replace macaddress WITH TRIM(imptemp.mac_addres)
replace printername WITH TRIM(imptemp.printer_na)
SELECT imptemp
NEXT b
************************************************************
* Progress Bar *
************************************************************
For I = 26 TO 100
for x= 1 to 40000
next x
Thisform.Pageframe1.Page2.Olecontrol1.value = ((I*100)/100)
x=0
Next I
else
endif
SET SAFETY ON
SET EXCLUSIVE OFF
thisform.Pageframe1.page2.Text4.value = ""
thisform.Pageframe1.Page2.Olecontrol1.Visible = .f.
thisform.Pageframe1.page2.Text3.visible = .f.
thisform.Pageframe1.page2.Command9.visible = .f.
thisform.Pageframe1.page2.Label4.visible = .f.
thisform.Pageframe1.page2.Refresh