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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call another form from a button of a form? 2

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
585
PH
Hi everyone... i have my first form that displays a lot of information, i.e name, surnmae, mobile etc. I have put a button where i plan when clicked it will show another form.... i already design the second form... which i named sasma receipt.scx... the button on the first form has this codes... (as researched in the internet...they said just call the second form. so i did)... unfortunately everytime i click the button to see the second form, nothing happens... Thanks in advanced...

PROCEDURE CmdAux.click()


DO FORM "c:\users\oscar\onedrive\documents\visual foxpro projects\SASMA Receipt.scx"



ENDPROC
 
Nothing happens" means you neither see the form nor do you get an error, right?

The only thing that will look like that is the form releases just as it shows or it shows off display.
Do two things to check out possible problems:
1. Open the SASMA receipt form in the form designer and go into properties. Look into what position is stored into the top and left properties of the form.
2. If it's not positioned at a too high top or left position off display, then put something like MESSAGEBOX('Init') into the Init of the form to see whether you really call it. Also check if it releases automatically right after showing by adding a MESSAGEBOX('Unload') into it's Unload event in the form designer.

That's not a fix, but will show you what happens. By the way, you can see event happening without programming MESSAGEBOXes into events, there is the recording and logging of events possible, too, but for the moment that's more complicated to explain, I'll just mention to track events there is the debugger menu Tools and there "Event tracking". That'd enable you to see what happens if you keep the debugger window open and start your main form and test your button. At the same time it's lesson #1 of a debugger 101, that debugging usually works best when the debugger is already open while you run code you want to debug.

And debugging is what you're doing, you want to find out what's buggy.

Chriss
 
Hello Mandy,

Where exactly are your putting this code? It should be in the Click event of the button. But that doesn't look right, because you can't put a PROCEDURE statement (nor an ENDPROC) in an event.

What you should be doing is this:

- In the Form Designer, double-click on the buton.

- This will open an editing window. In the right-hand drop-down at the top of this window, select Click.

- Type this line in the edit area:

DO FORM "c:\users\oscar\onedrive\documents\visual foxpro projects\SASMA Receipt.scx"

Nothing else. No PROCEDURE or ENDPROC.

When you save and run the form, it should work.

However, I would also strongly advise you not to include the full path to the form in your code. Better to use SET PATH to establish a search path, and then to simply say DO FORM "SASMA Receipt". That way, it will be easy to move the app to another folder or another computer, or to change the directories on your hard drive.

However, that last point is separate from getting the form to work, so focus on that first.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Ys Chris no error message no form shown...

Mike... i dont a form designer, i have design the form manually... is it class? (i dont if im giving you the righ terms...pardon me, novice...)
what i have is...

ADD OBJECT cmdAux AS CommandButton WITH ;
TOP = 360, ;
Left = 550, ;
Height = 35, ;
BackColor = RGB(0, 128, 0), ;
ForeColor = RGB(252, 252, 252), ;
Enabled = .t.,;
width = 150,;
fontsize = 18,;
fontname = "BERNARD mt CONDENSED",;
caption = "Auxilliary"

PROCEDURE CmdAux.click()


DO FORM "c:\users\oscar\onedrive\documents\visual foxpro projects\SASMA Receipt.scx"
*do form c:\folder\form.scx


ENDPROC

 
Hmm. Looks OK to me.

Why don't you comment-out the DO FORM, and put, say a MESSAGEBOX() in its place (temporarily). That will tell you if there is something wrong with your code, or if the fault lies in the SASMA Receipt form.

If the MESSAGEBOX() works, then check the SASMA form. Could it be that it is present but not visible? Or could it be behind another form?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
If your form is defined in a PRG by code you can't DO FORM ... SCX, you have to have an SCX file to start it with DO FORM.

You have to have an error in that case, don't you see an error message box pop up? How's that possible?

Chriss
 
Ok Mike... I'll try, to see... and be back here.... Thanks...
 
Hi experts! Good afternoon... i think i have found the answer... i have this code in my procedure init () "_screen.Visible = .f."
so i just made the false into .t. and it showed my second form... my problem is even the VFP window is showed when the second form is called... please help me remove the vfp window even if the seond form is shown? Thanks everyone...
 
Mandy,

Even if it's now working, you may want to (or already) know these:

Is the 2nd form in the screen? The ShowWindow property can affect how the form is shown. Try the different values.

If the screen disappears, you may want to set the Desktop and Visible properties of the 2nd form to .T. to make sure it is visible.

Steve

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top