0

hello there,

anyone can help...
is this possible?
i have a string value of form names in my DB so when my condition passes, the variable string will take over the value , then that value will call the form(variable) as string.
i got an error when i use this code.

dim objForm as form
dim sValue as string

sValue="frmXXX"

set objForm=sValue
objForm.show

This is what the code looks like... i need to convert the variable string to form object

thanks a lot.

5
Contributors
10
Replies
14
Views
9 Years
Discussion Span
Last Post by anrico
0

This sample may help :

Mbt925, thank you so much for the help...
You have a good solution... i already do that kind of code, only applies to loaded/Active forms but in my case i will not load any form on it, just call them even unload/inactive...
just convert the string variable into object form name that i really needed.

thank you so much for the help...
maybe you have some ideas about this, i just want to call/show the forms in a generic way, i made a program to be a user defined function call.

is this idea possible? any help pls.

0

yah! i know its hard to do, but i am just asking if it is possible...
i already got the answer to my question. their is another way how to show the form via variable and my problem solved already...
thanks a lot for the support... hope we could share again later some ideas in developing software.

well, if you dont mind can i have your asl pls?
thanks! God bless.

0

i already got the answer to my question. their is another way how to show the form via variable and my problem solved already...

if possible , put your answer for this problem here ?

0

dim objForm as form
dim sValue as string

sValue="frmXXX"

set objForm=sValue
objForm.show

This is what the code looks like... i need to convert the variable string to form object

thanks a lot.

If you already have the forms made, that really shouldn't be a problem. Use a Select CASE statement.

Dim strFormName as String

Select strFormName

Case "formXXX"
     formXXX.show
Case "FormX1"
     FormX1.show
Case "FormX2"
     FormX2.show
End Select
0

if possible , put your answer for this problem here ?

yah! ok...
well, in my solution you can solved in two ways, provided the form exist in your project
if not error will take over:

sValue="frmXXX"

#1 'You can use the add command
set frmName=forms.add("sValue")
frmName.show

#2 'Using the CallByName function in VB6
set frmName=CallByName(Forms,"Add",vbMethod,sValue)
frmName.show

you can use either of this two solution i have.
This idea comes in my mind its because i managed more than a hundred forms in one project and i dont want a conditions or a hard coded, it makes your code messy.

anyone can use this code...

1

If you already have the forms made, that really shouldn't be a problem. Use a Select CASE statement.

Dim strFormName as String

Select strFormName

Case "formXXX"
     formXXX.show
Case "FormX1"
     FormX1.show
Case "FormX2"
     FormX2.show
End Select

hi hkdani,
Thank you so much for the solution I really appreciated.
Well, that was my old approach or old way of showing form,
i put it in the module all of them.
i think that could be applied to less than a hundred forms, what if you have more than a hundred you will declare all.

what i am trying here is to call the specific form from the table without any conditions and hard coded way, all are variables.

as of now i have more than 150 forms in a project.

thank you, hope we could share ideas later.
God Bless my friend.

0

yah! ok...
well, in my solution you can solved in two ways, provided the form exist in your project
if not error will take over:

sValue="frmXXX"

#1 'You can use the add command
set frmName=forms.add("sValue")
frmName.show

#2 'Using the CallByName function in VB6
set frmName=CallByName(Forms,"Add",vbMethod,sValue)
frmName.show

you can use either of this two solution i have.
This idea comes in my mind its because i managed more than a hundred forms in one project and i dont want a conditions or a hard coded, it makes your code messy.

anyone can use this code...

hi Neophyte08,

it works, but when i'm using MDIForm and MDIChild set to TRUE, the form that i called using this method, the form loaded twice / there are 2 form (same form).

is there any solution for this ?

thank;s

0

hi Neophyte08,

it works, but when i'm using MDIForm and MDIChild set to TRUE, the form that i called using this method, the form loaded twice / there are 2 form (same form).

is there any solution for this ?

thank;s

Use Public Sub in child form, for example:

'Call Child Form from Parent Form
Private Sub cmdCallChild_Click()
childform.loadme Me
childform.show vbModal
End Sub
---------------
'Variable Declaration on Child Form
Dim SForm As Form

Public Sub loadme(pForm As Form)
Set SForm = pForm
End Sub

Private Sub Form_Load()
txtSample.text = SForm.AnyControlOnParentForm.text
cmdButton1.text = SForm.AnyControlButtonOnParentForm.Caption
End Sub

Private Sub cmdAboutParentForm_Click()
Msgbox SForm.caption
End Sub

Private Sub cmdClose_Click()
Unload Me
End Sub

Edited by anrico: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.