How To VbNormal The Main Form After VbModal Form Closes?
I have a main form and a secondary form. The secondary for is a "psuedo-wizard" style for to allow the user to walk-through changing some program variables. It is called from the main for like this:
Main Form (frmMain) Calling Secondary Form (frmCustomCP)
Private Sub mnuCenterPoint_Click()
frmCustomCP.Enabled = True
I'm using the vbModal style because I don't want the user to be able to do anything else until they either finish the second form or close it. So, in the second form I've got a bunch of other things happening. When I close it, I have to set some variables back to 0 (these are global variables) and then close the second form and "re-open" the main form (preferably back to the same state (either "vbNormal" or "vbMaximized") as it was before the second form was launched.
Here's the code I'm using to do that:
Code for closing secondary form
Private Sub Form_Unload(Cancel As Integer)
intWizardLevel = 0
lngNewPointLat = 0
lngNewPointLng = 0
frmMain.WindowState = vbNormal
This doesn't appear to be working. After the user "finishes" the wizard, there is an update to the database. After the update, I do a "Unload Me", and then, the closing code should take place (I believe). However, the form seems to load back to it's normal size, but then gets minimized again.
Any idea's on how I can make the frmMain return to it's previous size (and be displayed) when I close the frmCustomCP??
Thanks in advance for any help you can give.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Call Main Form Sub From VbModal Form
I'm currently converting my Access Project to a vb6 project. I have 2 forms. The Main Form (frmMain) opens the 2nd Form (frmComm) upon clicking a button (vbModal). I would like to call a subroutine on the Main Form from the 2nd Form (frmComm), as the Main Form has a MSComm control that is used for receiving and sending data. In Access, I could just Call the Subroutine as follows:
How do I accomplish this in VB6 code?
Close Main Form When Another Closes
I have read through other posts I could find on this topic, but am still unclear. Here's the problem: In my program the main form has a button that opens a new form using hide/show. What I want to happen is for the whole program to end if the new form is closed. What would the code for this look like?
Opening Main Form In VbModal???
I have a program with one form (non-MDI). The form is the "Startup Object". Is there anyway I can start the program where the form is in vbModal. I don't wish to use any API calls, ie; SetWindowPos.
Closing All Forms When Main Form Closes
I have a form and a dialog in my project. When I close my form I want my dialog to close also. I see that there is no Close() method (as in .net) so I was wondering the process.
Edit: I am also wondering how I could close a form via a button control (since there is no Close() method).
Make A Main Form Using MDI Form And Child Form
How can I create a child form that attached to the MDI form so that the MDI form and the child form looks like a single main MDI form in runtime ? I've tried to made it by disabling the min & max button of the child form and then load the child form in the MDI Form Load method, but with that way the child form can't be seen at the runtime.
Pls help me
Display Form But Keep Executing Code In Main Form (think I Need A Splash Screen ..)
I've got a form which i have calling up a progress form. this form just has a label adn a progress bar on it. however, after i call up the form to be visible, i need to be able to keep executing my code in the main form, and simply update the progress form's progress bar and label. I think i need a splash screen, can someone point me in the right direction?
Open New Form Based On Main Form Primary Key (coding Issue?)
I am having trouble opening a new form with "child" data from my main form.
Basically I would press a button on my main form & want to open a new form listing the data based on a related key "txtFields(0)" from my main form
Here is my code on the "child" form - my main form button code is just "frmStudents.show"
Private Function initDatabase() As Boolean
rs.Open "select * from Transactions where account = '" & frmMain.txtFields(0) & "'", cn, adOpenKeyset, adLockOptimistic
Set .DataSource = rs.DataSource
On Error GoTo 0
initDatabase = True
I call the "initDatabase" sub in the form load event of the "child"
I get a datatype mismatch error
Each Child transaction has a unique key of TransactionID & a joined field of AccountID, which would align with txtFields(0) from the main form.
Edited by - vwalla on 11/18/2004 12:21:20 PM
Accessing Data From One Form From Main Form In Visual Basic 6
How do I extract data from a form into the main form for processing? For
instance, I have several image files in a form called images(images.frm),
indexed from 0 to 99, and I want to import these into a variable array in my
main form, main (form1.frm). How do I code a control to get these images
into an array in my main form from the images.frm?
Show A Form Without Main Form Running Code
I'm trying to show a form (frmDriveSelect), but I don't want any code to run in the main form until the form I open (frmDriveSelect) closes. Any ideas? I tried "Show vbModal, frmDriveSelect" but that says form is already showing, which it isn't.
Want An Added Form To Be The Main One That Leads To The Existing Form?
Hi Vb Experts gain;
I have an existing application, I added to it a second form with many new controls on it, and I want this second form to be the first displayed form in design time then through one of its buttons it opens the existing form. is that possible? or shall I reverse the analogy of my design? and restart to design by order of priority first designed is first displayed...?????
M C Benzerari
Display Information On Main Form That Is Gathered On Second Form.
I am using a serial barcode reader to scan information into a label on a form that is NOT my main form. I would like to display this information on my main form as well. Actually, I am using the comm event from the scanner to capture the information so even if the second form is not open, I want to display the information on the main form (in a label). So...to hopefully simplify my question....How do I display information from one form to the main form.
How Do I Make My Sub Form Visible In Front Of The Main Form
The form.show command is not getting getting the form to be visible in front of the main form. How can I get it to be visible in front of the main form. I've tried form.show and form.visible. I've also tried making the main form main.hide and mainform.visible = Flase. This still does not work.
Pass Dataset From Main Form To Form With CR Viewer
What I am trying to do is this. I have the main form say form1 that uses ADO.NET. I run a query and pull back all the info to a dsReport dataset. Now I want to pass that dataset to another form called frmReport. This for has a CrystalReportViewer on it. I want to take the filled dataset from form1 and populate the CR Report on frmReport.
Dim crReport As rptReport
crReport = New rptReport
CrystalReportViewer1.ReportSource = crReport
Text Of Other Form Appears Sometimes On My Main Form After Resizing
hello, i finally got my resizing code working and with that, i encountered a strange thing
When resizing my main form, sometimes the name property of one or two textboxes of another form appears. This form however isn't loaded. The text doesn't also always appears! I have attached a screenshot to visualize my problem (see red ellips).
Someone knows why this happens? If you need more info, let me know.
Problems Showing The Main Form In Sub Main()
My application use a Sub Main() to loadup a slash screen, while I do some initialising work, and then loads up the main form with frmMain.show.
The frmMain has lots of controls on it, some 3rd party, and also 2 userControls of my own.
One of my users has reported, that once the splash screen has been displayed, the app then just 'hangs' before frmMain is displayed. However, this works fine on many many other PCs.
I have lots of tracing in my app, and I can see that all the init stuff works, and it gets to the bit before it does the frmMain.show, but it never gets to the frmMaim_Load() event.
I have some tracing in the UserControls, and I see that both of these execute the Initialize, ReadProperties and ReSize events, but thats it.
I presume, that there is something wrong with one of the other 3rd party controls I'm using, and for some reason they are 'failing' in some way.
Does any one know of any tracing for other was to figure out what is going on between me issuing the .Show command, and the Load() event firing?
Thanks for you help,
ProIV Resource Centre <a href='http://www.proivrc.com'>www.proivrc.com</a>
Display Form Ontop Of Main Form
I am trying to do the following: When a user clicks on a button, a form pops up with some buttons on it. The problem I am having, is when that new form appears, I don't want the user to be able to click on or access the Main form until they click a button on the new form. I guess this would be like writing a MSGBOX. The user needs to click something on that message box before they can do anything on the main form again. How can I accomplish this with a form?
Thanks for your help!
Child Form Without Main Form Flickering
I want to show a form as a child of another form (NOT A MDI APP).
I use the SetParent. It works well but the main form title bar flickers because the time i load the form and the call of SetParent the mainform lost the focus and the color of the title bar changes and makes some flicker effect.
Could you help ?
When A Form Closes...
When a form is closed with the 'x' in the upper right corner, is there any sort of special event that takes place? Currently I have a form with a listbox and a button. Double clicking in the listbox or clicking the button is the equivalent of ok or accept. The x is the equivalent of cancel. So if the x is pressed, I would want to load a variable with like, -1 since that cant be used by the list. Any help plz!! Thanks!
FTP - Form Closes
I have a vb6 app that uses winnet.dll. When the program loads, the user can then open another form to download and uploads datasets to our ftp server. The users clicks a button and the program goes through the connection process, this then normally popluates a list view with the datasets they can download.
However for two users out of 30 users, the form that displays the list view and carries out the ftp process completely disappears and the connection to the server drops. The intial login form and program is still active and they are still connected to the internet.
I remote controlled their laptops and I am able to browse the ftp server through IE, without the connection dropping.
The users are connecting via adsl / wanadoo ( france )
Does anybody have any ideas as to why this may be happening and how I may stop the form form closing.
for more information I am connecting in passive mode.
Form Always On Top And VbModal
I used this code to make my form Always on Top
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, _
ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_SHOWWINDOW = &H40
Const HWND_NOTOPMOST = -2
Const HWND_TOPMOST = -1
' Set a form always on the top.
' the form can be specified as a Form or object
' or through its hWnd property
' If OnTop=False the always on the top mode is de-activated.
Sub SetAlwaysOnTopMode(hWndOrForm As Variant, Optional ByVal OnTop As Boolean = _
Dim hWnd As Long
' get the hWnd of the form to be move on top
If VarType(hWndOrForm) = vbLong Then
hWnd = hWndOrForm
hWnd = hWndOrForm.hWnd
SetWindowPos hWnd, IIf(OnTop, HWND_TOPMOST, HWND_NOTOPMOST), 0, 0, 0, 0, _
SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW
But the execution sequence continues on so that even though the user input is accepted the code that uses it (in the calling function) has already executed.
How do I make a form both always on top and modal? Thanks.
Is there any way to show a vbModal form but my background form still running while the modal form is shown?
VbModal Form Within VbModal Form?
I think I found my core problem to an earlier post...
I have Main Form A which calls vbModal Form B.
In the event Form B cannot do its job, the error handling prompts the user for additional information on vbModal Form C (Retry, Continue, Abort), and clears the Error object.
When a user clicks on a decision on Form C, I need Form C to go away, partially because on "Retry," it could come back again.
I have attemptedCODEFormC.Hide: Set FormC = Nothing
How To Set Vbmodal In The Form?
Hi, I'm having a difficulty to show a form as modal in the following
Prior before the change in my project, I have a standard exe that calls an
activeX dll. This dll will populate different kind of form based on the
parameters pass out from the exe. Some of these form require administration
right and some are not. In order to prevent the access to the first form
before the second form (modal) is closed. I've set these form as modal i.e.
frm.show vbmodal <-- this work fine!
Now, I have to deploy this project in a windows vista environment and due to
some of the forms require an administrative right. So, I have to change the
program and made it an UAC compliance. So, I've created an intermediate exe
file called dllWrapper Eg:-
Standard exe --> dllWrapper file --> activeX dll
Because of this, now the vbmodal doesn't seem working anymore. May I know
how to overcome this problem?
Thanks in advance
Vbmodal In Form? What Is This?
i have 2 forms ( fmrlistview and frmalbum) ; 1 consist of listview and the other consists of 7 text boxes. i want my data from my 1st form ( which is frmlistview) to load to my 2nd form(which is frmalbum). so everytime i double click my 1st form(frmlistview) i will show my 2nd form( frmalbum) loaded of the data i selected from 1st form (frmlistview) but the error was "MDI child form cannot be loaded modally". why is it? whats wrong?
here's my code:
Private Sub lstAlbum_DblClick()
mbooladd = False
strsql = "Select *From Album_Artist where ItemNum = " & fListView.lstAlbum.SelectedItem.Text & ""
Set RS = New ADODB.Recordset
RS.Open strsql, ConnectString(), adOpenForwardOnly, adLockReadOnly, adCmdText
frmAlbum.txtAlbumID = !Itemnum
frmAlbum.cboAlbumType = !Itemtype
frmAlbum.txtAlbumCode = !Itemcode
frmAlbum.txtAlbumTitle = !Title
frmAlbum.Text1 = !Artist_Number
frmAlbum.txtArtistCode = !ArtistCode
frmAlbum.txtArtistName = !Artist
Call frmAlbum.Show vbmodal
I have a Form 1,2, and 3.
In Form1 I show Form2 ( vbModal ):
Now I want to show Form3 from Form2. Is this possible? I do need the vbModal unless there is another function that does the same and allowes me to open a form from a vbModal form? Thanks In advance.
if my application is running minimized, I want to pop up a form with a message. I've tried with form1.show vbmodal
but it shows behind other running applications (for example: internet explorer), does anyone know how can i show it infront of all other applications?
How To Open Another Form Within The Main Form
Hello everyone! Could anyone please tell me how I might call a about form within the main form? In my program I will have a menu and a about button in the menu and when the user clicks it, it will direct to the about form. Thanks !!
Second Form Centered In Main Form?
I never thought about this until today, how do I get a second for to be centered in the main form?
For example, I have a form and when i press a button a second form opens over the top of the first form but its smaller so you can still see the edges of the first form.
I have everything set to center but if i move the first form to the edge of the screen and click the button the second form opens in the middle of the screen and not in the middle of the first form.
How is this done?
A Form Which Should Apper For Few Second Before The Main Form
I dont know how should i call it, flash form or........
In my project i have put the form, which supposed to appear when i run it which should last for at least 30sec,like when you open a word document, and then the main form should appear.
But when i debug that form apper and it doesnt call the other form. How can i do it.
Usercontrol Closes The Form
How do you get to unload a usercontrol and close the form (completely unload the form) from the Usercontrol's code??
Progress Bar Form And VBModal
If I open a form used as a progress bar in vbmodal then the execution stays with the new form how do I then get the execution back to the originator...
i.e. I want a vbModal Form to pop up when the user is doing something that will take time to complete and in the mean time I dont want the user clicking on the rest of the application...
Form.show Vbmodal ~help
I have a button on an application that allows the user to open up a second application if needed. Below is the code that I am using.
RetVal = Shell("C:
etworkpathdatainfo.exe " & dbsA.Name, 1)
These are two separate apps which need to remain separate and both running on the desktop at the same time.
I would like the second app that was called from the first to be closed also "IF" the first application is closed(and the second app is still open of course). This would make it easier for the user to have both applications close with less work.
Is this possible and if so, how?
Form VbModal Problem
I have problem here. I want to unload the form 4 "Pemilik lot" and set modal to form11 ("Pengurusan maklumat") when I click X button. Why the form11 appear first? I want to unload form 4 first and show form 11 later and set form 11 as modal. Why my form appear like this?
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
(vbmodal) For A Child Form
I need to force a child form to stay on top
until its unloaded or hidden. (vbmodal doesn't
work with child forms)
Here is my problem:
After execution of line "frmDetalj.Show vbModal, frmMain", should some TextBoxes be populated with Recordset-values, and then some of text boxes (initially: 'txtMyTextBox.Locked = True') have to be 'Unlocked' or disabled, so att user can change values in some of them, but all I get is a form without any values in my textboxes and textbox-property settings are not maded like I want it. If I change the line to "frmDetalj.Show" it works. Why? How can I have both things work properly(vbModal form and txtBoxes to do what they have to do)?
' if I leave this : "vbModal, frmMain" bellow, it does not work properly
frmDetalj.Show 'vbModal, frmMain
on error resume next
frmDetalj.txtArende(0) = !ArendeNr
' ... and so on ...
frmDetalj.txtArende(12) = !Status
How To Know Which Button Pressed When A Form Closes
Forgive me I am sure this is really easy, but I do not know VB at all, and I got stuck with a program.
I am showing a form by calling this...
This opens another "window" which collects data from the user, then the user can either hit the OK or CANCEL button. How does the calling function know what button the user pressed?
I assume that you could do something like this...
ButtonPressed = Form1.Show 1
but you can not.
Can any one help me answer this easy question?
Thanks a lot, I appricate it.
VbModal Form Not Closing Properly
I have a main form (frmGame) calling a vbModal (frmHiScores) like this:
When frmHiScores is closed the program returns to frmGame but part of the frmHiScores remains visible for 1-2 seconds - very disturbing.
I tried everything I know: unloading frmHiScores, setting it to hide, even setting it to Nothing, setting Redraw to true. Still doesn't work.
Can anybody tell me what I'm doing wrong? Or give me a work-around? Thanks.
Unload Form Which Is Loaded With Vbmodal
I have a problem in coding to unload a form which is loaded with vbmodal. The form does not have any button (similar to splash form), and will be unloaded by code. The code looks like this
Private Sub CmdOK_Click()
'Calling some other procedures
The splashform remained on top, and wasn't unloaded, so it seems frmSplash.unload does not work if I set the form show with vbmodal.
Does anyone know how to fix the problem?
Thanks for any advise.
VbModal And Unable To Get Focus To Form
I have a program that's manipulating another program as it runs. While it's doing that, it does some exports of text files that need to be checked before it continues to run. If there is a problem, the program needs to prompt the user to override the normal settings and checks or fail the program. So, I added a login form to do this. It uses active directory to get to users on the network and works great.
However, when I use a frmLogin.Show vbModal to get the form to show up, it will show up and stop the program, waiting for input. However, the form is completely hung up. It's as if the form is disabled. Clicking it doesn't do anything, and I can't click on VB to see if it's really hung. However, all I have to do to make it focus and enable is minimize other windows on my desktop. I can't move the form, and if I click on another window, I lose focus and can't get it back till I minimize another window.
What's going on?
Problems After Form Loaded Vbmodal
At the moment, I have the following code attached to the DblClick event of a combobox.
frmConfigPricing.Show vbModal, Me
when you've finished on the modal form and you return to the main form, the program has the focus and all is good in the world.
But if you try to click on the X of the main screen, you need to click twice to make the program exit.
Also, while the keyboard works (tab to next then data), on occasion it makes the mouse cursor dissapear and it wont come back (except when over the taskbar) until the program is closed.
I'm not sure if it has to do with being a modal form or what ... but I really cant see that I'm doing anything else wrong.
Does anyone have any ideas?