Thanks, I appreciate that as that was a very hard problem to figure out and I'll look into that in the future for future developments. Record00 was initially @ResultSetCurrentPosition() but seeing as that would be fraught with issues, such as if the user sorted the result set or any number of other reasons like that a record was deleted or something, I decided to do something different with that field. I decided to create my own internal record number. So I use XResultSetValue() to automatically add a number to that record. But it only does it when On Element Entry of the Add Picture button. And since it's a relational database it knows to only create these record numbers for just that main record that it's working with, in this case the Customer. Here's the code I have established for that:
ACTION :: Add_Picture :: On Element Entry
#include "sbasic_include.sbas"
var vName as String
var vList as String
var vUser as String
var vFolder as String
var vDir as String
var n as Boolean
var vCWD as String
var vFile as String
var vCmd as String
var vShell as String
var vHandle as Int
var vFN as String
var vCount as Int
var vTemp as Int
var vCustomer as String
If @Mode() = 1
{
If @Len(Record_ID) > 1 Then
{
vName = Record_ID
vUser = @GetLocalEnvVar("USERPROFILE")
vFolder = vUser + "\Google Drive\AAction Photos\" + vName
vList = @LocalListDirectory(vFolder)
If Not (@DirectoryExists(vFolder))
{
n = @CreateDirectory(vFolder)
If (n = True)
{
@Msgbox("New folder created.",vFolder,"")
}
}
vCWD = @LocalCWD()
LocalCWD(vUser + "\Downloads")
vFile = @LocalFileDialog("Add Picture", "*.{jpg,jpeg,png,tiff,gif}")
LocalCWD(vCWD)
If vFile > " "
{
vDir = vUser + "\""Google Drive""\""AAction Photos""\" + @CHR(34) + vName + @CHR(34)
vCmd = "move" + " " + @CHR(34) + vFile + @CHR(34) + " " + vDir
vShell = @Shell(vCmd)
}
vList = @LocalListDirectory(vFolder)
PopulateListelement(Pictures_List, vList)
vHandle = @XResultSetNew(@FN, "ACTION!Pictures")
XResultSetCreateNewRecord(vHandle)
vFN = @AccessStringArray(@ReverseStringArray(@Replace(vFile, "\", ";")), 1)
XResultSetValue(vHandle, "Filename0", vFN)
vCount = @CountStringArray(@LocalListDirectory(vFolder))
XResultSetValue(vHandle, "Record00", vCount)
vTemp = @XResultSetValue(vHandle, "Record00")
vCustomer = Record_ID
XResultSetValue(vHandle, "Customer_ID", vCustomer)
XResultSetClose(vHandle)
FormCommit("ACTION")
}
}
It's important to note that the Pictures element of this and the "Descriptions" element of this is completely seperate. The "Pictures" subform actually does not house any pictures like one might think, like having an image box or something. All it houses is the record number field (Record00), a filename field (so it's linked to the Filename of the picture that's selected in Pictures_List), and a Description field. And the whole point of the whole subform is to just have a text editor Description box for each picture that is in a way linked to it, and pulls up automatically when you click the picture and then disappears when no picture is selected, and saves automatically and all that.
The other code heavy part of this system is:
ACTION :: Pictures_List :: On Element Immediate Change (This is the List Element that populates the Pictures directory; the folder in Google Drive that syncs between Server and Client computers.)
#include "sbasic_include.sbas"
var vName as String
var vUser as String
var vFolder as String
var vFile as String
var vFN as String
var vCust as String
var vHandle as Int
var vRec as Int
var vPos as Int
var vHandle2 as Int
var vLdSpec as Int
var vStSpec as Int
If @Mode() = 1
{
If @Len(Record_ID) > 1 Then
{
vName = Record_ID
vUser = @GetServerEnvVar("USERPROFILE")
vFolder = vUser + "\Google Drive\AAction Photos\" + vName
vFile = vFolder + "\" + Pictures_List
SetAltImagePath(Picture_Preview_Box, vFolder)
Picture_Preview_Box = vFile
//Displays a variable picture at a variable image path in an image box.
vFN = Pictures_List
vHandle = @XResultSetSearch(@FN, "ACTION!Pictures", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Filename0=" + vFN)
vRec = @XResultSetValue(vHandle, "Record00")
XResultSetClose(vHandle)
//Extracts record number.
vCust = Record_ID
vHandle2 = @XResultSetSearch(@FN, "ACTION!Pictures", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Customer_ID=" + vCust)
XResultSetSort(vHandle2, "Record00:-1")
XResultSetCurrentPosition(vHandle2, vRec)
vPos = @XResultSetCurrentPosition(vHandle2)
XResultSetClose(vHandle2)
//Looks up the current position of that particular record from a full result set of that customer's subrecords
//and stores it in a variable.
FormResultSetCurrentPosition("ACTION!Pictures", vPos)
//Goes to the position of the stored variable, for the current result set, of the "Pictures" subrecords, for the
//current customer.
If @IsBlank(Pictures_List)
{
SubformVisibility("LE3", 0)
}
Else
{
SubformVisibility("LE3", 1)
}
}
}
I also forgot to mention that another function of the description field is to be automatically inserted into an email when I click another button On Element Entry, that would be the Attach button, then there is a Send button to Send Email with those attachments and those descriptions inserted into the Email.
It's really cool that Sesame has these types of Email functions but I almost wish it had more than just sending and counting emails because then you could almost just use Sesame as your Email client and there would be no need for an external email client.