Normal Topic Automating routine tasks. (Read 6198 times)
cbislander
Full Member
***
Offline



Posts: 103
Joined: Mar 22nd, 2018
Automating routine tasks.
May 15th, 2021 at 10:00pm
Print Post Print Post  
Below is the automated task that occurs when I start this database.  It will only work if he text files below exist, which is only after the other locations do their backups.

On Application Open

Var vI as Int


    IF FileExists("\\SESAMESERVER\DATA\ANT\ANT1.TXT") Or
        FileExists("\\SESAMESERVER\DATA\NG\NG1.TXT") Or
        FileExists("\\SESAMESERVER\DATA\SR\SR1.TXT") Or
        FileExists("\\SESAMESERVER\DATA\SM\SM1.TXT")    Then
    {
//        If @AskUser("There are files to be imported.", "", "Do you wish to import them now") Then
//        {
            ClientLocalValue("CLVImport", 1)
            vI = @SelectTreeItem(@Application + "!Forms!Add Data!CUSTOMER!CUSTOMER")
           @SAVE
           @EXIT

//        }
    }

On Customer Form Entry

//In the example above I am using Customers as the database and Form name. Then in your Form's On Form Entry event, you would put code like the following.

Subroutine CheckForFileAndImport(vFilePath as String)

    If FileExists(vFilePath)
    {
        RunImportSpec(vFilePath)
        If @ResultSetTotal() > 0 Then
        {
            FileDelete(vFilePath)
        }
    }

End Subroutine




Var vI as Int
Var vFile as String

If @ClientLocalValue("CLVImport") = 1 Then
{
    vI = @LoadImportSpec("ALL")
    ClientLocalValue("CLVImport", 0)
    If vI = 1 Then
    {
        vFile = "\\SESAMESERVER\Data\Ant\ANT1.TXT"
        CheckForFileAndImport(vFile)
        vFile = "\\SESAMESERVER\Data\NG\NG1.TXT"
        CheckForFileAndImport(vFile)
        vFile = "\\SESAMESERVER\Data\SM\SM1.TXT"
        CheckForFileAndImport(vFile)
     vFile = "\\SESAMESERVER\Data\SR\SR1.TXT"
        CheckForFileAndImport(vFile)
    }
}



There is another form in this database that I use to post changes to the inventory.  I have to open that form and click 2 buttons to do it.

The first button is to Retrieve Unposted Sales

var vTmp as Int
var vList as String
var vChoice as String

     If @Mode() = 1
     {
           vTmp = @SelectTreeItem("Search Update Menu!Search (F7)")
     }
     If @Mode() = 2
     {
           vList = @SpecCommand(6, 1, "")
           vList = "Current Spec;" + vList
           PopupSelectPosition(4, @XPos(ThisElement), @YPos(ThisElement))
           vChoice = "DATE"
           If vChoice <> ""
           {
                 If vChoice <> "Current Spec"
                 {
                       vList = @SpecCommand(0, 1, vChoice)
                 }
                 vList = @SpecCommand(2, 1, "")
           }
     }

The second button is to post the changes
var vTmp1 as Int
var vTmp2 as Int
var vList as String
var vChoice as Int

@save

vTmp2 = @LoadRetrieveSpec("DATE")
@save

If @Mode() = 2 Then vlist = @SpecCommand(2, 1, "DATE")
@save
                     
vTmp1 = @LoadMassUpdateSpec("COMM-SPC-INV")

If vTmp1 = 1  Then RunMassUpdateSpec()


How do I place this programming in the automated part of the form?
  
Back to top
 
IP Logged