×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
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

RE: How to call another form from a button of a form?

"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

RE: How to call another form from a button of a form?

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

RE: How to call another form from a button of a form?

(OP)
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

RE: How to call another form from a button of a form?

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

RE: How to call another form from a button of a form?

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

RE: How to call another form from a button of a form?

(OP)
Ok Mike... I'll try, to see... and be back here.... Thanks...

RE: How to call another form from a button of a form?

(OP)
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...

RE: How to call another form from a button of a form?

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

RE: How to call another form from a button of a form?

(OP)
Ok Steve... Thanks...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close