Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I specify what I want in ShowMessage? 2

Status
Not open for further replies.

delphiman

Programmer
Dec 13, 2001
422
0
0
ZA

I need to have (something like) the following which is obviously wrong. What should the code be?


ShowMessage ('Account' + dmStdAcc.qryGLGLNo.value + 'already exists. Delete it.');

Anyone?
 
You need a message dialog - eg:
Code:
  MyResult := MessageDlg('Account' + 
    dmStdAcc.qryGLGLNo.value + 'already exists. Delete it?',
    mtInformation,[mbYes, mbNo],0);


[tt]MyResult[/tt] returns the value of the button you chose - so you can take the appropriate action. There a set of buttons available for use, as well as dialog types - [tt]mtInformation[/tt] refers to the type of dialog - basically changes the icon in the dialog.

Check out the [tt]MessageDlg[/tt] help for more information.

There are also a bunch of third party extensions to this, that extend the control - including a few on the Delphi 6/7 distribution disks

Good luck!

Chris ;-)
 
or like this
Code:
if MessageDlg('Account' + 
    dmStdAcc.qryGLGLNo.value + 'already exists. Delete it?',
    mtInformation,[mbYes, mbNo],0)=mrYes then do somthing;

Aaron Taylor
John Mutch Electronics
 
Sorry guys! You have both got it wrong!
The message is making a STATEMENT. It is not asking a question.

My problem is that the following bit doesn't work :)

+ dmStdAcc.qryGLGLNo.value +

Any more suggestions?
 
I assume that this '.value' is a string?

Steve
DNA still on the way, as is the new release of Star............
 
You can use the original ShowMessage or MessageDlg, but ensure dmStdAcc.qryGLGLNo.value is a string. So if it's a float then use:
Code:
+ FloatToStr(dmStdAcc.qryGLGLNo.value) +
or if it's an integer use:
Code:
+ IntToStr(dmStdAcc.qryGLGLNo.value) +

There are other formatting routines depending on your needs but these are the very basic ones for real and integer values.

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
What is dmStdAcc?
...And what is qryGLGLNo?

I assume qryGLGLNo is some kind of query field.

Try use dmStdAcc.qryGLGLNo.AsString instead.

KungTure-RX.jpg

//Nordlund
 
You might want to consider using ShowMessageFmt as this combines the ShowMessage and Format functions.
Code:
  ShowMessageFmt ( 'Account %s already exists. Delete it.', [dmStdAcc.qryGLGLNo.AsString] );
Like Nordlund, I'm assuming that qryGLGLNo is a TField.

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top