Jump to content

bazzer747

Members
  • Content Count

    53
  • Joined

  • Last visited

Everything posted by bazzer747

  1. bazzer747

    Closing Forms from other forms

    Hi, My application has a series of 3 forms, one where a User views some names, a second where the User selects some of those names, and a third where the User can view the names and manipulate them. I create all the forms modally, which means when I get the 3rd form those other 2 forms are still visible but are not required any longer. But the User can only close them when he closes the 3rd form. Also, it's not very good UI for him to go through that process. What I'd like is for the 3rd form, when it is opened, to close the previous two forms. What I've tried is this code in FormActivate: var MyHandle: tHandle; begin //If you came from Select Teams then close that window ... MyHandle:= FindWindow( nil, 'Select Team' ); SendMessage( MyHandle, WM_CLOSE, 0, 0 ); Application.ProcessMessages; Which only seems to work AFTER I close the 3rd form. Is there a way to close the previous forms as soon as the 3rd form opens?
  2. bazzer747

    Delphi Closedown Error

    Hi I'm running on Delphi 10.3.3 Enterprise. After a day's coding when I close Delphi I more often than not get the attached error happening. An access violation in rtl260bpl. Would you know if this is something that should never occur, or 'just one of those things'? It doesn't affect anything, Delphi runs as well as it always has. I often have 2 instances of Delphi running as I often copy over code from one project to the next, or form objects. This always works with no problems; I did think this might be the problem but I've done some testing and it's not something that is a hard error and doesn't happen every time. Could it be the bpl is corrupted in some small way that only complains under certain conditions. Or something like this. Any thoughts would be helpful.
  3. bazzer747

    Closing Forms from other forms

    Anders, Yes, it's a small application (mind there are about 30 different forms). The 3 forms I'm talking about lead naturally from one to the other - from the main form the first form opens viewing a list of names - if there are enough names the 2nd form is selected, this 2nd form selects from those names and leads to viewing them in the 3rd form (where many other operations can be done). It would be clumsy to do the opening (and closing) from the main form, going back then forward. If it is possible to close the form you have just come from, then that seems to me to be a much more efficient and better User experience.
  4. bazzer747

    Delphi Closedown Error

    Yes, you're right. Not causing any problems, just annoying. I suppose it gives me a feeling that the application isn't as stable as it ought to be, considering the cost of it. And that other things may not be working as they should be, but I can't see them. No worries, I just thought someone may know exactly what the cause was and had a solution.
  5. bazzer747

    Delphi Closedown Error

    Sorry, don't use GExperts. Might try the MadExcept, although I'm not really that deep into Call Stacks or the like. If it can point to any bit of code that I have created that would be perfect, but if the problem is in the VCL itself or the IDE or elsewhere inside Delphi I'm not sure I can do much (maybe report it to Embarcadero).
  6. bazzer747

    Where did I come from

    Hi On a form I have a dbgrid and a radiogroup. When a User clicks on the dbgrid I read a table which updates relevant radio buttons in the radiogroup ( a Yes, Maybe, No selection). If a User clicks one of the radio buttons it fires off table updates (setting the Yes, Maybe, No fields). However, the click on the dbgrid also sets the radio buttons by reading the information on the row clicked, which in turn is firing the radiogroup onclick event, which I don't want to happen. Is there a way to 'know' what component was used when running a procedure. This way if the dbgrid was where it came from I could bypass the updates. I've used Sender several times, but this seems to only say what form I came from.
  7. bazzer747

    Where did I come from

    Dany, Works a treat - once I got my head around the logic of what goes where :-). Many thanks for the tip. Gunther, will try your method as well. Attila, this seems like another way, which would avoid the complication I got myself into, so I'll also try this. To all, many thanks.
  8. bazzer747

    DBGrid Row Selection Issue

    Hi I have two forms, each with a dbgrid showing items from different tables. On one grid when I select a row itrow highlights and the rows showing in the grid remain unchanged, as does the location of the row I selected. Using the up/down arrows moves the selected row up/down. On the other grid when I select a row it immediately re-positions that selected row to the middle of the visible rows. Using the up/down arrows the row selected remains exactly in the vertical centre. In the properties I can't see any differences between the two dbgrids, but would really like both dbgrids to behave the same way, whichever one of the above I don't mind. Any thoughts would help.
  9. bazzer747

    DBGrid Row Selection Issue

    Found the answer! When I click on a cell in the grid I do a LocateEx on the fields value, this changes the record pointer which is causing the selected row to reposition itself in the centre. Not sure why this is, though. However, I replaced the LocateEx with a Lookup (which doesn't alter the record pointer) and all works as it should do now.
  10. bazzer747

    DBGrid row colours

    Hi I have two dbgrids, one with the Default Drawing property unchecked, the other with it checked. This latter is because I need to colour certain columns according to their values. On both I have AltRowShading checked with a slightly darker row colour, which works fine. When I select a row which has the alternate colour in the former dbgrid the color changes to a light blue on which the black text is clearly visible. However, on the latter when I select an alternate row the colour changes to a dark blue and the black text is not easily visible. I can't see anywhere a way to change this dark blue to be the same on both dbgrids, and the only difference in all the properties is the latter has default drawing checked. Any thoughts would help.
  11. bazzer747

    FireDac Query Issue

    Hi, I'm using a FireDac query to select different sets of data in an MSSQL database. I open the first query like this: dm.fdq.Open('SELECT * FROM tblUsers WHERE MSL = :pMG ORDER BY Sname, Fname',[ 1 ] ); which works fine. I then need to select a different set of records so I issue this (assuming this replaces the above statement): dm.fdq.Open('SELECT DISTINCT Fullname, Fname FROM vPGCEnrolments WHERE MatchGroup = :pMG AND MatchYear = :pY AND YES = 1',[ gvMatchGroup, gvYear ]); This works but I start to get Access violation error messages. The select works fine though, as the correct data displays. As I think this has something to do with the select statement I issue the following statement at the end of this procedure: dm.fdq.SQL.Clear; .. but when I look at the SQL string with ShowMessage( dm.SQL.text ); it still shows the Select Distinct line shown above. The Clear statement doesn't seem to clear anything. I've saved the SQL (assigning dm.fdq.SQL.text to a variable: cSQL, at the start of the procedure), and at the end of the procedure restore with dm.fdq.SQL.Add( cSQL ); but this does nothing either. I've a feeling I'm not understanding how the above should work correctly. Any advice would be appreciated.
  12. bazzer747

    FireDac Query Issue

    Many thanks for your help. I've now used the temporary query setup and it works a treat, no errors or glitches. Live and learn 🙂
  13. bazzer747

    FireDac Query Issue

    Ah, thankyou for the post. I've learnt using FireDac mainly from youtube and the like, so no formal training. Trial and error a lot of the time, eventually that gets me there. The temp connection route you mentioned seems like a definite way. So a 'close' on the query does what exactly (in terms of any SQL code in the query)?
  14. Hi, I have searched for 'simple' stuff in using FireDac but havn't found the answer to the following, which would save me lots of keying ... I have a datamodule with a fdQuery & Datasource, and the fdQuery has the following: 'Select * from tTable where Company = :pC order by oOrderName' - so a parameter is created in the query. If in my code I want to set the query to different values do I have to do the select statement again in it's entirety, like: dm.fdc.Open( 'Select * from tTable where Company = :pC order by oOrderName', [ 'Debenhams'] ); Or can I simply specify the new parameter value like: dm.fdc.Open( '', [ 'Woolworths' );
  15. bazzer747

    FireDac Select with parameter, how to renew

    Many thanks, both - I will certainly use these methods. The shorter version Serge mentioned I saw in a YouTube on Tips & Tricks by Dmitry Arefiev CodeRage 9.
  16. bazzer747

    FireDac MySQL Connectivity

    Hi I'm trying to use a MySQL database on a remote MySQL Server. I've setup the Firedac TFDConnection with the correct parameters but when I try to test I get the following message: 'Cannot load vendor library [libmysql.dll, libmariadb or libmysqld.dll) The specified module could not be found Hint: check it is in the PATH or application EXE directories, and has x86 bitness' (see attached screenshot). I then went to the Embarcadero docwiki site which says much the same with a little more detail. I've followed the links it has for the libmysql.dll library and download it and put it in my EXE directory. However, when I try the test again I get the same message. I've closed Delphi (10.3.3) down and tried again but still get the same error message. Has anyone had similar issues and can suggest a way to fix this?
  17. bazzer747

    Debug v Release problem

    Hi, Something really strange, which I've never seen before in creating my apps (all Windows 64bit). When I run the app in Debug mode it runs fine, albeit 38mb in size. When I run it in Release mode (14mb in size) it fails with an access violation after the main form shows and I click on a button which links to another form. I can only think it has been something I have done and I'm frantically looking at all the changes I've done recently. Another oddity is that I have a Splash screen showing whilst the app is initialised, which is hidden before the final Application Run. However, the Splash screen is still showing (in the Release) after the main form shows, which is very odd as I have 'fSplashscreen.Hide; fSplashScreen.Free; immediately before the Application.Run command, which doesn't make sense. It does seem this is where the problem is, but I cannot trace this as it all works OK in Debug mode. Any thoughts would be appreciated.
  18. bazzer747

    Debug v Release problem

    Hi Sorted! The mystery was why it was OK in Debug but not in Release mode, I found the answer was I was trying to force connection to a Test Server and forgot (idiot!) to connect all the queries to the Test Firedac connection. The Splashscreen stayed on the screen because (trying to figure what was wrong) I had added the Splashscreen to the forms created at initialisation time and one was already being created, so there were two of them - only one was closed. As always, a silly mistake on my part, sorry to have bothered you before I did more thorough checking.
  19. Hi I'm having great difficulty in getting the syntax correct on a query I need to make via a Firedac Q!uery. Basically I want to set a WHERE clause that picks up all records that have a 'S' or 'R' in a certain field. In 'normal' SQL this codes like this: SELECT * FROM tTableName WHERE Status IN ('S', 'R') ORDER BY EventDate ... which works fine on the SQL Server, but how do I do this via a Firedac query? It may look something like this: qQueryName.Open('SELECT * FROM tTableName WHERE Status IN :pSR ORDER BY EventDate',[ ('S','R') ] ); The issue is how do I format the parameter - the above doesn't work, nor any of the different ways I can think of of setting the parameter to 'S','R'. Any help would be appreciated.
  20. bazzer747

    GetLastAutoGenValue

    Hi I've just seen the above function which Firedac provides, and read the DocWiki about it and it would be very helpful in my project as I create new records. However, I'm having difficulty understanding quite how it works, or rather what it requires passed with it. The Docwiki provides an example of how to program with it: ShowMessage(VarToStr(ADConnection1.GetLastAutoGenValue('MyGen'))); My question is - what is 'MyGen' referring to? I'm using MS SQL and the info says the method returns the last autogenerated value in the session. In my table I have an autogenerated column called 'ID' (an integer). I've changed the above example to read: ShowMessage( VarToStr( dm.fdcMSLTest.GetLastAutoGenValue( 'ID' ))); assuming what it wants passed to it is the fieldname that is autogenerated. However, this gives an error when run 'Capability is not supported'. Any thoughts would be appreciated.
  21. bazzer747

    GetLastAutoGenValue

    Works a treat, many thanks. Why can't the documentation be a little more helpful, especially as the guys who are looking this up won't know how to use it. Frustrated, but glad for this forum 🙂
  22. bazzer747

    RadioGroup Oddity

    Hi, I have a table which has an internal calculated field nHcap. It is a numeric field with values from 1 to 54. In the table I have another field which has a value of either 'Div 1', 'Div 2', or 'Div 3'. I use a RadioGroup with these three values available for selection, and when a selection is made I filter the table to show only records that have a certain nCap value. These values are 'Div 1' from 1 to 17, 'Div 2' from 14 to 21, and 'Div 3' from 20 to 54. The OnCLick event for the RadioGroup looks like this: procedure TfLadyMembers.rgDivsClick(Sender: TObject); var cChoice: String; begin dm.vMembers.Filtered:= False; //Start with clean slate cChoice:= rgDivs.Items[ rgDivs.ItemIndex ]; with dm.vMembers do begin if cChoice = 'Div 1' then Filter:= 'nHcap < 17'; if cChoice = 'Div 2' then Filter:= 'nHcap > 13 AND nHcap < 21'; if cChoice = 'Div 3' then Filter:= 'nHcap > 20'; Filtered:= True; end; if cChoice = 'All' then dm.vMembers.Filtered:= False; end; The problem I'm seeing is that when 'Div 1' is first clicked the filter gives incorrect records. Clicking the other buttons gives correct results, and subsequent clicks on 'Div 1' gives the correct results. I've traced the code in debug mode and the correct select/filtering is executed, so why am I getting incorrect records on the first selection. Very odd.
  23. bazzer747

    RadioGroup Oddity

    Just to finish this off, as no one has replied :-). I've changed from using Filter (as this fails with strange error conditions and incorrect results) to using SetRange, which works perfectly, and much quicker.
  24. bazzer747

    RadioGroup Oddity

    An extra 'oddity' is that when the first click on 'Div 1' produces the wrong set of records I sometimes get an error message to the effect a Bookmark is not found. I am not using Bookmarks so this is something internal.
  25. bazzer747

    RadioGroup Oddity

    An extra 'oddity' is that when the first click on 'Div 1' produces the wrong set of records I sometimes get an error message to the effect a Bookmark is not found. I am not using Bookmarks so this is something internal.
×