• Welcome, Guest. Please login.
 
May 20, 2019, 12:36:57 pm

News:

Welcome to the SQLitening support forums!


Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Fredrick Ughimi

1
Thank you, Cj.

Your last post gave me an idea that works. Using the same table twice. Not the most elegant code, but it works.
It does what I want.

m_sDate = VD_GetText (nCbHndl, %ID_FRMJOURNALENTRY_DPKDATE)
             
m_sReference = VD_GetText (nCbHndl, %ID_FRMJOURNALENTRY_TXTREFERENCE)
If Trim$(m_sReference) = "" Then
      MsgBox "Please, enter Reference", %MB_TASKMODAL Or %MB_ICONINFORMATION, VD_App.Title
      Control Set Focus nCbHndl, %ID_FRMJOURNALENTRY_TXTREFERENCE
      Exit Method
End If
               
m_sNarration = VD_GetText (nCbHndl, %ID_FRMJOURNALENTRY_TXTNARRATION)
If Trim$(m_sNarration) = "" Then
      MsgBox "Please, enter Narration", %MB_TASKMODAL Or %MB_ICONINFORMATION, VD_App.Title
      Control Set Focus nCbHndl, %ID_FRMJOURNALENTRY_TXTNARRATION
      Exit Method
End If
             
m_sAccount1 = MLG_Get(hJournalGrid, 1, 1)
m_sDescription1 = MLG_Get(hJournalGrid, 1, 2)
m_sDebit1 = MLG_Get(hJournalGrid, 1, 3)
m_sCredit1 = MLG_Get(hJournalGrid, 1, 4)   
             
m_sAccount2 = MLG_Get(hJournalGrid, 2, 1)
m_sDescription2 = MLG_Get(hJournalGrid, 2, 2)
m_sDebit2 = MLG_Get(hJournalGrid, 2, 3)
m_sCredit2 = MLG_Get(hJournalGrid, 2, 4)
             
slExe "Begin"
   slExe slBuildInsertOrUpdate("tblJournalEntry", SQLiteDate(m_sDate) & $Nul & m_sReference _
   & $Nul & m_sNarration & $Nul & m_sAccount1 & $Nul & m_sDescription1 & $Nul & m_sDebit1 _
   & $Nul & m_sCredit1)
slExe "End"
       
slExe "Begin"
   slExe slBuildInsertOrUpdate("tblJournalEntry", SQLiteDate(m_sDate) & $Nul & m_sReference _
   & $Nul & m_sNarration & $Nul & m_sAccount2 & $Nul & m_sDescription2 & $Nul & m_sDebit2 _
   & $Nul & m_sCredit2)
slExe "End"

MLG_PUT hJournalGrid,6,3,TotalCredit(hJournalGrid),0
MLG_PUT hJournalGrid,6,4,TotalDebit(hJournalGrid),0

? "Record Saved!", %MB_TASKMODAL Or %MB_ICONINFORMATION, VD_App.Title
2
Hello Cj,

QuoteI don't know what column/row from the grid to put into the table columns.

All columns of the grid and all rows containing records because the rows could contain up to 3 records sometimes, but most of the times 2 records.

Kind regards.

3
Hello Cj,

Attached JournalEntry.jpgis my form.
4
Thanks CJ. The thing is the values entered in the textboxes (Date, Narration, Reference) is usually a record, while the values entered on the grid (Account, Description, Credit, Debit) are usually two records or more per transaction. That is doing the double entry in Journal Entry of Accounting.

I would post a picture of my form in my next post whenever electricity comes on.

Best regards.
5
Hello CJ,

Thanks for the heads up and great code as always. Since you did not use MLG and Textbox in your codes, it is a bit difficult to follow and adapt.

Regards.

6
This saves but giving undesirable results. Three rows instead of two. Repeating the second row:

rows = 2
cols  =7
 
RowStart=1    'select first row from mlg
RowEnd=2     'select last  row from mlg
ColStart=1    'need entire record
ColEnd=cols
ReDim FromGrid(RowStart To RowEnd,ColStart To ColEnd) As String 'dim array
MLG_GETEx hJournalGrid,FromGrid()                                      'fill array
For r = RowStart To RowEnd
    For c = colStart To colEnd
        sb.Add slbuildbindDat(FromGrid(r,c),"T") 'add bind string into stringbuilder
    Next
Next
slExeBind slBuildInsertOrUpdate("tblJournalEntry", "?" & $Nul & "?" & $Nul & "?" & $Nul & "?" & $Nul & _
"?" & $Nul & "?" & $Nul & "?"), _
slBuildBindDat(SQLiteDate(m_sDate), "T") & _
slBuildBindDat(m_sReference, "T") & _ 
slBuildBindDat(m_sNarration, "T") & _
sb.String,"V" + Format$(cols)
? "Record Saved!", %MB_TASKMODAL Or %MB_ICONINFORMATION, VD_App.Title

I might have to break table into two.

7
Hello,

I have a tricky situation trying to save values from a textbox and MLG on a FORM into a table at the same time.

On the FORM we have 3 values from Textboxes and 4 values from the MLG. On MLG there are two or three
rows to be saved at a time.

Has anyone done this? Any pointer would be appreciated.
8
Hello CJ,

Thanks as always.

Both samples code works good. I think I would go with the second one. I did something similar to that earlier.

The tricky part is:
Quote
2. Automatically upload records entered in local database to the remote server when the internet connection is available.


The client computers are multiple, not just one.

9
Not sure if the applies here.

https://www.sqlitening.planetsquires.com/index.php?topic=3204.msg16315#msg16315

Quote
Yes, you can switch back and forth between local and remote mode by using
slPushDatabasae, slSetProcessMods, and slPopDatabase.  Look at ExampleA.Bas
and study the L modchar in slSetProcessMods.

The below does a connect, switches to local mode, gets the data from a local
file and then switches back to remote mode.
Code: [Select]
   slConnect
   slPushDatabase
   slSetProcessMods "L0"
   slGetFile "Your file name here", YourStringVariable
   slPopDatabase
   slSetProcessMods "L1"


Would give it a shot.
10
Hello,

Wondering if these two scenarios could work. Program running over the internet with the client machines having their own database as well.

1. Automatically switch between Local and Remote access depending on the availability of internet connection. If internetconnection do remote else do local.

2. Automatically upload records entered in local database to the remote server when the internet connection is available.

Are these scenarios feasible?
11
Hello CJ,

I mistakenly was changing the values of the same Database in another directory. My mistake.

Works great! Thanks once again.
12
Yes. I understand the values are read into aData array.

aData(x-1) = VAL(sArray(x)) read each value into the aData array


Just that the values in my table doesn't reflect what the Chart says. Maybe I am doing something wrong. I would check.

Thanks a lot.
13
Hello CJ,

Excellent. Thanks for the sample code. The problem is how do I individually read each values into the
aData array subscripts.

aData(0) = ? : aData(1) = ? : aData(2) = ? : aData(3) = ? : aData(4) = ?

Best regards.

14
This is verbose, limiting and not flexible, but it works.


'****** Read data values ******
    REDIM aData(4)
    LOCAL dTemperature1 AS DOUBLE
    LOCAL dTemperature2 AS DOUBLE
    LOCAL dTemperature3 AS DOUBLE
    LOCAL dTemperature4 AS DOUBLE
    LOCAL dTemperature5 AS DOUBLE
    slSEL "SELECT Temperature as ITemperature1 FROM tblObservationChart LIMIT 1"
    IF ISTRUE slGetRow() THEN
       dTemperature1 = VAL(slFN("ITemperature1"))
    END IF
    slCloseSet

    slSEL "SELECT Temperature as ITemperature2 FROM tblObservationChart LIMIT 2, 1"
    IF ISTRUE slGetRow() THEN
       dTemperature2 = VAL(slFN("ITemperature2"))
    END IF
    slCloseSet

    slSEL "SELECT Temperature as ITemperature3 FROM tblObservationChart LIMIT 3, 1"
    IF ISTRUE slGetRow() THEN
       dTemperature3 = VAL(slFN("ITemperature3"))
    END IF
    slCloseSet

    slSEL "SELECT Temperature as ITemperature4 FROM tblObservationChart LIMIT 4, 1"
    IF ISTRUE slGetRow() THEN
       dTemperature4 = VAL(slFN("ITemperature4"))
    END IF
    slCloseSet

    slSEL "SELECT Temperature as ITemperature5 FROM tblObservationChart LIMIT 5, 1"
    IF ISTRUE slGetRow() THEN
       dTemperature5 = VAL(slFN("ITemperature5"))
    END IF
    slCloseSet
    aData(0) = dTemperature1 : aData(1) = dTemperature2 : aData(2) = dTemperature3 : aData(3) = dTemperature4 : aData(4) = dTemperature5


Any better suggestions would be appreciated.

Best regards.
   
15
Hello Everyone,

I think RMChart is pretty straight forward. Its just reading the values from SQLitening as double array that is where I am stuck.

From RMChart sample: '****** Read data values ******


REDIM aData(0) AS DOUBLE
REDIM aData(4)
aData(0) = 30 : aData(1) = 40 : aData(2) = 70 : aData(3) = 60 : aData(4) = 20


How do I translate the above, reading from SQLitening table? I have tried using slSelAry, it uses string array, but RMChart requires double array. I really stuck and I need some help.

Thank you in advance.