101

(5 replies, posted in SQL queries)

DriveSoft wrote:

Also you can call procedures using button with action "SQL Query"

Could someone comment more on that? How do you call a procedure using a button with action "SQL Query"??

102

(8 replies, posted in General)

Thanks Derek, I have tried that with a datetimepicker but got errors about an incompatible "extended" type, hence my question to understand what it was for!

103

(8 replies, posted in General)

DriveSoft wrote:

Check it out

procedure frmComissoes_OnShow (Sender: string; Action: string);
begin
   frmComissoes.dtIni.datetime := SQLDateTimeToDateTime(SQLExecute('SELECT MIN(Data_Venda) FROM Vendas'));
   frmComissoes.dtFim.datetime := SQLDateTimeToDateTime(SQLExecute('SELECT MAX(Data_Venda) FROM Vendas'));
end;

Can somebody explain this please? How do you use this : SQLDateTimeToDateTime?

104

(25 replies, posted in SQL queries)

Thanks Sparrow, I learned a lot!!

Does anyone knows if I can call a function from within a "SQL Query"- Button or do I have to call all my button SQL queries from the script tab? I tried and I get a SQL error...

105

(25 replies, posted in SQL queries)

What if I have multiple date columns with different names? Is there as simpler way of setting a date format for any date/datetime column to be used within a SQLite query or do I have to write numerous procedures for each and every column having a date.

Up to now, I do have 8 columns in different tables containing a date: Release_date, Purchase_date, Return_date, etc... using Sparrow's code is limited to one column named "dat". Is there a trick ? I am calling on all advanced programers here, I already spent hours on StackOverflow and most people are limited to one date field.

106

(25 replies, posted in SQL queries)

sparrow wrote:

Advanced mode for dates.
Supported (d, dd, M, MM, yy, yyyy in different combinations + different separators)
Something like this.

Works great, I wonder if we could write a function and keep the manipulated date format in a global variable as I have dates in multiple tables with different field names, to avoid writing the whole block for each and every procedure in a quite big project.

107

(25 replies, posted in SQL queries)

sparrow wrote:

The simplest option.

Thanks a lot Sparrow, the simplest option does not work for the US format and probably for other countries using the M/d/yyyy as a date format.

108

(25 replies, posted in SQL queries)

I am pretty sure Dmitry uses a function to display the date with the local format but no one knows how it works except for Dmitry.
Anyway, I have been playing around with the registry keys, I can get and use the values of short date and time format but I must transform the returned value to work with SqLite queries format!!

So far, I got this but I need to re-format the registry key output to match "%d" for day, "%m" for month and "%Y" for year as the registry spits out the system format for the short date which is "dd" for day, "mm" for month and "yyyy" for year with whatever separator you have set. Is there an easy way or do I have to write a whole lot of CASE...?

begin
  reg := TRegistry.Create;
  reg.Access := KEY_READ;
  reg.RootKey := HKEY_CURRENT_USER;
  reg.OpenKey('Control Panel\International',false);
  shDate := (reg.ReadString('sShortDate'));                    // Get short date format but must be set to %d/%m/%Y or whatever order/separator for the date
  lgTime := (reg.ReadString('sTimeFormat'));                   //Get Time format but must be set to %H:%M:%S
  reg.Free;
  form1.tablegrid1.dbSQL:= 'select strftime("'+shDate+'", date) as "Date" from date'; //returns only the registry key value instead of formatted date
  Form1.TableGrid1.dbSQLExecute;

end;

109

(25 replies, posted in SQL queries)

I have actually sent a screenshot in my previous answer to show that using any kind of datetostr variance does not help to make "universal" application, I wish I knew what is behind the tablegrid auto display query for the dates as it uses the regional settings every time.

110

(25 replies, posted in SQL queries)

No need for a screenshot.

Let's say my regional settings are set to this date time format: DD/MM/YYYY HH:MM:ss

Date time are stored in ISO8601 format by default when using SQLite : YYYY-MM-DD HH:MM:ss

Using a table grid to get a date time value returns the date in my regional settings: DD/MM/YYYY HH:MM:ss, if I change my regional settings, the results are displayed using these new settings.

Using an SQL query without forcing the date time format returns the ISO8601 date time: YYYY-MM-DD HH:MM:ss

unless someone knows a script that would force the date time to display using the regional settings.

My point is that I am a European living in the USA and their date time format is different compared to many countries and I am developing an app not only for the US but also for other countries and some of my grids require SQLqueries that cannot be made using the tablegrid default queries (i.e: complex joins). Not to mention that date separators differ from country to country: France is dd/mm/yyyy, Sweden is yyyy-mm-dd, Germany is dd.mm.yyyy, USA is mm/dd/yyyy and... the time in the US is in 12 hours format with AM and PM.

111

(25 replies, posted in SQL queries)

Does anyone knows a trick to display the result of SQL query including a date to be displayed in the localized date format the same way it does when using the auto display in a grid?

I already know how to force a date format with strftime with Sql but it becomes strange when the app displays a mix of date formats depending on how the grid has been designed, whether with autogrid or with an Sql query button/auto search.

This is important to me as I want the app to be international so I wonder what is used within MVD to display the date in local date format in the autogrids.

112

(23 replies, posted in Script)

CDB wrote:
sparrow wrote:

I
How do you like this?

I think Sparrow, where tcoton was having difficulty, was in trying to work out how to get an Image Click to do what a Button Click can do either by script or from the inbuilt functions for ShowRecord etc.


Not exactly, I was actually struggling to use the function “ShowRecord” with the proper syntax in a script which is :
form_where_the_record_will_show.ShowRecord(‘tablename’, form_containing_the_record_ID.tablegrid_or_combobox.dbitemID);

What is missing in the “documentation” is the actual syntax for each function, not everyone is an experienced developer.

113

(23 replies, posted in Script)

sparrow wrote:

I don't know what you're looking for or where you're looking for it.
Here is a link to the documentation http://myvisualdatabase.com/help_en/script_form.html,
and here is what you asked about.

procedure NewRecord (ParentTable: string = ''; ParentTableID: integer = -1)
 Prepares and shows the form on the screen for creating a new record. Similarly, if the forms were called by the button with the "New Record" action.

procedure ShowRecord (TableName: string; id: integer)
 Displays a form with data from the database for the specified record.

How do you like this?

I think you are over reacting to my initial question that has been answered by Derek and if you look closely to his answer, you will see how and why I was confused by the “documentation” and the actual way of using it.

114

(23 replies, posted in Script)

Thank you so much Derek, the contextual help was completely wrong for the syntax of "ShowRecord", you got it! The dbItemID also works with a Combobox.

115

(23 replies, posted in Script)

sparrow wrote:

So this is what you are waiting for. All combinations and secrets in one book?

Not really, but at least it ressembles something more of a user manual that never existed in the first place than a book of all secrets!!
Most of the time, I look on the internet in different places including this very forum before asking here.

Look, nobody can answer to the question of my post!! Good example of missing documentation if you ask me!! wink

116

(23 replies, posted in Script)

k245 wrote:

Colleagues, please be patient. Once I have completely transferred the contents of the beginner's tutorial to hyperbook format, I will translate it into English. Now there are many clarifications, additions and corrections to these materials, so English-speaking readers will be more lucky - they will immediately receive better information. But a little later.


Keep up the good work, I cannot wait to see the scripting section with all the possibilities that we don’t even know yet!

117

(23 replies, posted in Script)

Are you referring to this: => https://k245.ru/mvdb/non-code-prilozheniya-mvdb.html

It's great, lots of missing details from Dmitry's help file but not really easy for non Cyrillic readers as some texts are not translated at all by the auto translate features of our web browser!! wink

Below is copy paste from web browser after auto translate of this page : https://k245.ru/mvdb/otobrazhenie-tabli … annyh.html


WantTabs    Reaction to Tab    Determines the reaction of the component to pressing the <Tai> key. If the property is set to True, tabulation symbols are inserted into the text when the <THAT> key is pressed. By default, the WantTabs property is set to False, and when you press the <Tah> key, the table sends input focus to the next window control.

TabLeaveControl*    Loss of focus with the <Tab key    Determines whether the component will lose input focus when you press Tab

Хотите Возвраты*    Enable line feed with the Enter key    Determines whether multiline text will be allowed when you press Enter

Иинкрем, поиск    "SEARCH" button    A table can act as a filtering management tool if it is specified as a data source when configuring a button with the [SEARCH] action. In order for filtering to change synchronously with moving through the rows of the table, specify the button responsible for searching the data in this property.

118

(23 replies, posted in Script)

Which book??

119

(23 replies, posted in Script)

Hi Sparrow,

any comment about this? What are the options for styleelements?:

form1.button1.styleelements := 2;

120

(23 replies, posted in Script)

That's a clever way of doing it. I do a change of color/hue/saturation on MouseEnter and MouseLeave for my actionnable images, it's the same a passing by a button and I have your example for the "nudging". Thanks a lot Derek.

121

(23 replies, posted in Script)

I have tried that but there is an ugly arrow showing through. It does the trick for now but I really would like to use the script feature and the documentation is... slim.

122

(3 replies, posted in General)

How about this? : https://myvisualdatabase.com/forum/view … hp?id=8368

123

(3 replies, posted in FAQ)

What are you using? Abiword is a word processor, it is not designed to process spreadsheets. The button 'open to excel' is actually opening a CSV file. so if you want to open CSV files with a word processor, you must tell Windows to associate CSV files to a word processor.

124

(23 replies, posted in Script)

I might be dumb but I am struggling to use the procedure ShowRecord to actually work, whichever way I am trying, I get an error ')' expected at... or undeclared identifier: 'Users' at...

How do you write this procedure to display the record of say table 'Users' with the ID of the current form into another form the same way a button "Show Record" does?

Currently, I am trying to achieve this:

procedure Admin_UsrInfoBtton_OnClick (Sender: TObject);
begin
UserInfo.ShowRecord(Users,+Admin.User_ID.dbItem);
end;

The reason I want to script it is because I want to use an image instead of an ugly Windows button.

125

(3 replies, posted in FAQ)

I think that if you do not have Excel installed, Windows will ask you which program you want to use, set it to open by default. Have you tried?