How to update a recordset in livecode - livecode

I am using the code below to update the underlying database when users make change to a dataentry field which is displaying data from a recordset.
on CloseField
put "Update tblCases Set fldComment='" & field "txtComments"
& "' Where fldCaseID=" &
revDatabaseColumnNamed(intRecordsetID,"fldCaseID") into strSQL
runSQL strSQL
end CloseField
The underlying dabase is updated as expected but the recordset is not. So when the user move to another record then come back to the record that was updated the old data is displayed.
So I need a way to refresh the database which still displaying the current record.
`

To enhance efficiency, the record set is saved to memory. When you go back to the previous records, you don't go to the actual records of the database but to the records that were saved in memory. To update the record set, you need to run your query again, basically deleting the old cursor and creating a new one with the new data.

Related

How to take data from mongodb atlas and add to table on website?

the plan is to create a table on a website (link below) that users can add or remove data (a new row) to.
I have set up a form above the table (with POST) that takes data input into the form and then adds that data to a collection in my mongodDB atlas cloud.
This is fine so far, the problem is I dont know how to code to get that data to go from the db and append to the table (with GET) adding a new row simultaneously.
eg. You add data to form and press submit.
The data you submitted goes to database (set this up)
At same time, data that was just submitted is taken from database and added to the table on the webpage (permanently until removed).
I can show you the page i created so you can see what Im trying to do.
https://epsl.herokuapp.com/transfer_list
I am using node, mongo, mongoose, express..to set it up.
thanks.

Write from Excel to Access multicolumn combobox field using VBA

I have an Access file with two tables: users & products. Users keeps a list of who can write to the Access file (fields like userID, systemID, name). Products keeps a list of product attributes including who made the last update to the record. The last update field is a combobox with two columns: userID (bound to this), name (displays this due to column widths of 0";2").
I also have an Excel file, named simulator. Using VBA, the simulator reads from the products table, uses assorted prediction algorithms to simulate the product's future, then writes the predictions back to Access.
When Excel writes back to a product's record, I'd like to record the last update author to be simulator. Assuming this user exists (userID=100, name=Simulator, say), how do I do this?
I currently have
' Open Access database, get products table, get product record
connection.Open ...
products.Open "Products", connection, ...
products.Filter = "ProductID = " & productNumber
' Update record
products("LastUpdateAuthor") = "100; Simulator"
products.Update
products.Close
And this writes "100; Simulator" to the correct field. How do I get it to recognize that 100 is the bound column and Simulator is the second column?
Should only save the UserID into LastUpdateAuthor field. Then multi-column combobox RowSource should be an SQL statement of Users table in order to retrieve and view the related UserName. So have a record in Users with UserID 100 and name Simulator, then still just save the UserID.
As long as the RowSourceType is Table/Query, it will see the 100; Simulator value as a single string from the LastUpdateAuthor field. Can set combobox RowSourceType as ValueList then use code manipulating recordset and Add method to load the LastUpdateAuthor data to the RowSource and the semi-colon will be recognized as column separator. However, if you do as described in first paragraph, this should not be necessary.

Record insert/delete anomaly

I have the next problem to which I need help to solve.
There is a Workbook with three forms and a Database in Access.
There is a table in the DB called tblPlanungStatus where I record if a module is ready.
All three forms uses the table to either delete or insert a status into it.
There is an anomaly that occurs most of the time from Form3.
I insert the status, it runs without error. I run a query to count the recorords for this type and it comes back 1. Wich is good.
In the DB nothing happens, it shows no record added.
I run the query again and it says there is 1 record.
I run delete and the count says 0. So it seems to work. But in the DB still nothing.
I close the Workbook and run the count again and the record dissapeared, in the DB nothing shows.
If the record stays in the DB then when deleting it works, but after closing it comes back again.
Sometimes the record cannot be added, sometimes it cannot be deleted and when reopening the Workbook (which I don't know why matters) the record either deletes or adds.
In the DB the record appears and dissapears with a certain time, but not always.
I have been stuggling with this for over a week. Can anyone help me?
Thanks, Mike
Probably your Access database corrupted. Check this, especially "Number of records varies, depending how the data is sorted"

J2ME Record Store delete then insert Exception

I am working on J2ME Record Stores and when i delete the contents successfully, and then i check it, it gives me the correct count which is zero. But when i insert again, it gives me error finding record exception, because it is inserting after the content that i had inserted before. It is inserting from 2 instead of 1.
Can anyone explain why is it happening that way?
The record id in a recordstore is unique and auto-incrementing, just like a primary key in an SQL database. When 1 has been used, it cannot be used again. (Unless you delete the recordstore and create it again).

Updating a table Access and Excel VBA

I have one table called: Transaction. This table has the following fields: (ID,ProductName,Amount,Date) placed in an excel sheet that is connected with MS Access database. ID is the only unique field. Sometimes, my user submits a transaction that has let's say 5 records. Then, they want to modify the submitted data in case if they entered incorrect amount and they want to correct it. I want to write a code in VBA that will do the update. my current query is:
Update table Transaction(ProductName,Amount) set ProductName=#Product,Amount=#Amount)
where Date=#date;
This query does not work fine because obviously it replaces all the records data with the data of the last resubmitted record because my condition is weak. My difficulty is that I can't find a good condition in the where clause that will do the update a record by record accordingly.
Please help,
You will need to use the unique id of the record, in your case the ID field to guarantee you are updating the correct record.
Something like the following:
Update table Transaction(ProductName,Amount) set ProductName=#Product,Amount=#Amount) where ID = "id of record you want to update"
Enjoy!

Resources