|
-
Jul 18th, 2005, 02:45 PM
#1
Thread Starter
Fanatic Member
Help Routing Between Forms
I have a form named 'FrmCustomers' which contains a list box containing customers names, allowing the user to choose a customer to view ,edit etc.
This form may be loaded from a number of different forms within the app
i.e. assuming the app is in main form 'FrmMain' - to load customer form I use the following code:
Private sub CmdLoadCust_Click
Origin=Me.Name 'This is used to determine the original form
Me.Enabled=False
FrmCustomers.Show
End Sub
Now to return to the original form I put the following code in the form Unload event of the form 'FrmCustomers' :
Private Sub Form_Unload(Cancel As Integer)
if Origin="FrmMain" then FrmMain.Enabled=True
If Origin="Frm1"then Frm1.Enabled=True
If Origin="Frm3" then Frm3.Enabled=True
End Sub
etc. etc. etc.
My question is :
Is there not an easier way to return to the form which loaded FrmCustomers in the first place ?
Pse Help!!!
Ken
-
Jul 18th, 2005, 02:50 PM
#2
Re: Help Routing Between Forms
You could use a function to do it. Then pass the form as an argument. Something like this might work but I havn't tested it:
VB Code:
' in a module
Public g_Caller As Form
Public Function ShowCustomers(Caller As Form)
g_Caller = Caller
Caller.Enabled = False
FrmCustomers.Show
End Function
Public Function HideCustomers()
FrmCustomers.Hide
g_Caller.Enabled = True
End Function
You should probably add some error checking in there though.
-
Jul 18th, 2005, 03:20 PM
#3
Re: Help Routing Between Forms
It looks like frmCustomers is meant to be a Modal form. Showing a Modal form is similar to a message box, the user must complete the task offered by the Form before doing anything else. If that is the case then simply use
VB Code:
Private sub CmdLoadCust_Click
FrmCustomers.Show vbModal, Me ' the second argument is optional.
End Sub
When frmCustomers is Unloaded or Hidden, code execution returns back to the calling form.
-
Jul 18th, 2005, 03:28 PM
#4
Thread Starter
Fanatic Member
Re: Help Routing Between Forms
-
Jul 18th, 2005, 03:42 PM
#5
Thread Starter
Fanatic Member
Re: Help Routing Between Forms
Ps brucevde thanks this is exactly what I was looking for !
-
Jul 18th, 2005, 05:16 PM
#6
Re: Help Routing Between Forms
Good one brucevde. I didn't know about that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|