Hello,
My database has memo fields and the data entered into these by the user can be quite long. There are two of these memo fields in the report.
The record form has a button to press which prints a SQL report for just that single record and that works well. I have added text fields to the report for these two memo fields and right click on each to set "Stretch to Max Height". This makes the report print the full text consisting of a number of lines. I also set "Shift When Overlapped" so the lower one moves down when the field above.increases in the number of lines.
My question, how do I get the report to automatically add another page when the field text takes it beyond a single page? Is this possible?
Thanks for any help,
David

Hello Derek,
thank you for the ideas and the project. Both from you guys are excellent. I will be seeing the customer at the end of the week and tell them there are options. Really appreciate the input from you both.
Regards,
David

Hello Mathias,
thank you for your good work again. I can incorporate that into my project. I did not know about the AllowGrayed feature.
Thank you and regards,
David

Hello,
I have provided an application to a customer which they use to log all the technical work that comes in. The company assigns the job to a staff member who deals with it. Each service job record has a ComboBox dropdown field called Status and the user changes this as the job is updated. The values in this ComboBox are from a Dictionary table called Status. The user enters the status entries in the Status table to suit there needs and all works well. Currently they have values Closed, Completed, Open, and Started.
Once a job is invoiced in a separate invoicing software, the user sets the Status for the job to 'Completed'.
On the form that shows the list of service jobs, there are dropdown ComboBoxes for Job Status, Customer, and a Date field and these are all used on a Search button. Eg the user could Search for records with status Open for Customer name ABC.
In day to day use, the user would like to bring up the list of service jobs but not show jobs that have been invoiced as most of the interest is in the jobs that are still open. My question is how to do this, keeping in mind that the user has control over the Status field entries in the dictionary table. I am thinking about a CheckBox on the Service Job record labelled 'Invoiced'. If I do that, can that be used as part of the search button. Then the search would be along the lines of Status=OPEN and Customer=ABC and InvoiceCheckBox NOT Checked.
Does that make any sense at all. Ideally, I think it would be good if there was a CheckBox that can be included in the search button where the user selects whether to include invoiced records or not.
Any ideas would be appreciated.
Thanks, David

Hello Derek,
Hope you are well. Yes, thank you for helping make it clear. I have managed to incorporate the help from Mathias into my project and I am now storing the data in the data file automatically as it arrives in the serial port.
I break up the incoming stream using the SplitString command and I write that into TEXT fields in the data file. The telemetry data is numeric . I have a button that displays the data file fields in a spreadsheet. The spreadsheet shows the data as text, not numeric entries in the spreadsheet cells and that means I can't use a spreadsheet to do graphs. There might be some way to convert all spreadsheet cells to numbers in one go, I don't know. That possibly means I need to convert the sql fields to numeric.
Anyway, I am pleased with progress and I can show the customer next week.
Regards,
David

Hello Math,
thank you for the demo code. It inserts the various fields so can I learn from the format of your command.
I don't understand why you have made the date field into a TEXT field. Where a field is to be a date, is there some sort of rule to apply to determine when the field type should be a DATE or TEXT? What about if SQL SELECT commands are used on the data file and the field containing a date is a TEXT field?
Is there some condition where a field containing a time should be a TEXT field?
Thanks again for your help, really appreciate it.
Regards,
David

Hello Math.
Thank you. I have so far dabbled with it but now I am being asked to do so much more so it's essential I start learning this.
I break up the data string with SplitString which seems to work ok. I will look at the file in the morning that you sent.
Thank you for the help.
Regards, David

Hello Mathias,
In reality, my project involves various types of data such as Data, Time, Text, and numbers. There is hardware that forms the entire string and I receive the data through the serial port. The string is comma delimited and I get the various fields out of the string. The date and time is not part of the string received in the PC.
I wish to write the received data into a table using SQLExecute. The data and time part of it are just the local date and time on the computer and I would like to write this local date and time into the database for each record. The data is received in close to real real time so that is fine.
I attached an example so I could practice writing various data types into the file but it all went wrong and aren't sure where so I removed most of my SQLExecute and would appreciate it if you could complete that line for me.
In the test project attached, there are boxes to write a text and enter a integer and real number and these should all be written into the data file just one record at a time as the Add button is pressed.
I hope that makes sense.
Also, the SQLExecute lines become quite long so could you tell me the best way to spread a SQL command over multiple lines please.
No pressure at all, I am only progressing as I can and as others are able to help.
Thanks and regards,
David

Hello Mathias,
Thank you for the help. I can try this out in the morning and report back to you.
Regards,
David

Hello,
I would like the command to write the current time to a database field using SQLExecute please.

SQLExecute('INSERT INTO TestData (DataDate) VALUES (' + Time() +')');

At one stage I had it working so that it would put a time in the field but where it is 4:15PM here, it would have the time in the database as 3:15AM. Can anyone help please.
Thanks in advance, David

61

(9 replies, posted in General)

Hello Dmitry,
Thanks, that has solved it.
Still curious about these characters 13 and 10, I changed the two ReplaceStr lines to replace them with 'xx' and 'yy' as in the code below. The data lines print as they should with each transmission printed on a single line but now with xxyy on the end of each line. That isn't really expected. I attached a screenshot. Does this indicate something strange going on?

procedure OnRecieveComData(Sender: TObject; Data: string);
var
    sLine: string;
begin
    sLine := sLine + Data;
    if Pos(#13, Data) > 1 then
    begin
      sLine := ReplaceStr(sLine, #13, 'xx');                  // Radsoft
      sLine := ReplaceStr(sLine, #10, 'yy');                  // Radsoft
      TelemetryArray := SplitString(sLine, ',');
      Form1.Label6.Caption := TelemetryArray[0];   
      Form1.Label7.Caption := TelemetryArray[1];
      Form1.Label8.Caption := TelemetryArray[2];
      Form1.Memo1.Lines.Add(sLine);
      sLine := '';
    end;
end;

Regards,
David

62

(4 replies, posted in General)

Hello Derek,
thank you for the ideas, really appreciate it. I have tried it and it is knowledge that I can make use of.
Regards,
David

63

(4 replies, posted in General)

Hello ehwagner,
thank you for your help to understand this.
Regards,
David

64

(4 replies, posted in General)

Hello ehwagner,
thank you so much for all your help with this. Both methods work well. With the second one, I also added your same code to both OnKeyDown and OnKeyUp for the TableGrid so it now works for both using a mouse and for stepping through the records using the up and down cursor keys.
Thanks and regards,
David

65

(4 replies, posted in General)

Hello,
In an application I am working on, the application will read the computer user name using the GetUserName function. This is to be held in a variable and will be written into a field called "Owner" when the user creates a new record.
Once a record is saved, if it has the word "System" as its "Owner" field entry, it should not be able to be opened by pressing the edit button or double clicking the record.
Ideally, if someone tries to edit the record it will display a message box advising that the record cannot be opened.
I can read a field value when the Edit button is clicked but I don't know how to then intercept the process if the field has some particular value.
I hope it all makes sense and any help would be appreciated.
Thanks,
David

66

(4 replies, posted in General)

Hello,
The following works to change a table field without opening the record in a window.
SQLExecute('UPDATE Staff SET Location = "Away" where id =' +inttostr(form1.tablegrid1.dbItemID));
The above shows that the record ID in a table is a string, not an integer.
Selecting an individual record for printout in a report looks like the statement below.
WHERE employees.id = $id;
Why is a single record id written in different ways whether it is in a table or a report?
Is there some sort of rule to apply to know when to use the different ways of doing this?
Dumb question in know but I have to ask.
Thanks,
David

67

(9 replies, posted in General)

Hello Dmitry,
I added a button with the command
Form1.Memo1.Lines.SaveToFile('c:\Telemetry\MemoText.txt');
as you will see in the attachment. The saved file MemoText.txt is in the zip file. Please let me know if I need to get the data in some other way.
Thanks,
David

68

(9 replies, posted in General)

Thanks Dmitry,
When running the code you supplied, there is no data at all added to the memo field. I added a couple of lines as below.

procedure OnRecieveComData(Sender: TObject; Data: string);
var
    sLine: string;

begin
sLine := sLine + Data;
    if Pos(Data, #13) > 1 then
    begin
      sLine := ReplaceStr(sLine, #13, '');
      sLine := ReplaceStr(sLine, #10, '');
      TelemetryArray := SplitString(sLine, ',');
      Form1.Label6.Caption := TelemetryArray[0];
      Form1.Label7.Caption := TelemetryArray[1];
      Form1.Label8.Caption := TelemetryArray[2];
      Form1.Memo1.Lines.Add(sLine);
      sLine := '';
    end;
    Form1.Memo1.Lines.Add(sLine);        // Added by David
    sLine := '';                                                  // Added by David
end;

With the modified code as above, I get the data printed out again but in the incorrect way still.
I have checked the code for the micro controller and there is no control codes are anything else added. It is just simply ASCII characters.
Then I changed the code in the micro controller so it would send a shorter string. The problem remained in that the text added to the MEMO box is still spread over two lines.
I have now tried four other software programs which all display the received data correctly with the complete string as a single line.
Please find a text file attached which has data recorded with a comms program..
thanks and regards,
David

69

(9 replies, posted in General)

Hello Again,
please see the attached image which shows the data arriving and being displayed on another serial communication program. Each transmission is correctly displayed as a single line.
Thank you for your help, David.

70

(9 replies, posted in General)

Hello Dmitry,
Thanks. Please find the project attached and a screenshot is included in the zip file.
The string read into the COM port is about 50 characters and it arrives with the commas in place, just as you see it on the screen except when it is received in the MVD application, it splits the data across two lines. Then when I use the SplitString function, it only acts on the second line that appears in the window. Really I need to be able to split the string into its 8 parts.
I have tried several other serial communications programs and they always display the data as a single line each time a transmission is received.
I am using the latest version of MVD.
Once we get past this situation, I need to add another 20 to 30 bytes to each telemetry string.
Thanks for your help.
Regards,
David

71

(9 replies, posted in General)

Hello,
I have been using the COM port to receive data and it has been fine when receiving about 12 bytes of data, which is all I have required till now.
My new project consists of a microcontroller which is collecting telemetry, forming a text string about 50 bytes long, and that goes into the PC COM port. I started out using the standard COM port example from Dmitry as it receives COM port data and adds each newly received line into a Memo field. I did this to see how the data looks and to use it as a starting place.
Now when it receives 50 bytes of incoming data, it adds a line to the Memo field but it is only the first 31 bytes of the received data and then it adds the remaining 19 or so bytes in the following line. The entire string consists of 8 sections which are all comma delimited and when I use the SplitString function, it only splits up the data which appears in the second line of the newly added data in the memo field.
I know it is difficult to describe as I have hardware involved as well but I hope it makes some kind of sense.
Dmitry, is there some limit to the receive buffer size which could be causing this problem? Also is it possible to add a function that can report how many bytes of data are in the receive buffer? Some software allows being able to set the size of the receive buffer and that would be good too.
Thanks,
David

Hello tcoton,
thank you. I just found http://myvisualdatabase.com/forum/viewtopic.php?id=362 which must be the one you mean. It works. Only thing is that a field I change in the record is one that appears on the Tablegrid and once I save the record. The updated field entry does not appear on the Tablegrid. I need to press the SQL Query button again to make the grid show the updated data. I tried using dbUpdate on both on closing the form and after click on the save button but neither worked.
Thanks again for your help.
Regards, David

Hello again Derek, I also had to remove the SQLite.db file as it was 6Mb and the system wouldn't accept that size file so sorry but you will need to enter a record or two and put some text in the "Medical Issue" field of a record.
Thanks, David.

Hello Derek,
nice to hear from you. All is well here and I hope same for you. Its the middle of the night for you so you must really enjoy programming. I am working on a school project with my son so it is attached here but it is 16Mb zipped (remove image so file is small enough now). I did remove the image and resend if you it can't be sent as it is. Once you run it, please click the "Quick Select" button and then the "Medical Issues" button. I would like to be able to have the edit form appear and edit the "Medical issues" field. You will see that the other fields on the edit form are read only. Created in version 4. Hope it all makes sense. Thanks again and nice hearing from you.
Regards,
David

Hello,
this is the first time I have used a SQL Query button when displaying table records in a TableGrid. I press the button and the result of the SQL Query is displayed in the table with the headings all fine. I place a button on the form to edit the selected record but when I click the button, I get the message "No record selected for editing". I have created the edit button the same as I would for any other normal Tablegrid. So there is a difference between a normal table and when a SQL Query is used. Can somebody please help me so I can press the button to edit the highlighted record.
Thanks in advance for any help.
Regards,
David