tags:

views:

24

answers:

3

I am having multiple forms with Find button provided. The forms i am having are Contacts.vb and Users.vb, i want to use single Find.vb form for both of these forms. I mean whether a user presses Find button from Contacts.vb or Users.vb the same form should be opened with corresponding data that is fetched from database.

I tried using Find.Owner = Me from Users.vb but i don't know how can i determine from Find.vb that who is the owner.

I tried to use that if owner of find form is Users.vb then fetch data from users table and if owner is Contacts.vb then fetch data from Contacts table. Unfortunately i am not able to perform this task.

Please provide any proper solution or any other suggestion to perform this. Thanks in Advance

+1  A: 

Add a property (e.g. "PersonType") to the child form - set this from the parent just before showing the form - and then use the value of this property in the child to perform the correct search type.

Will A
+2  A: 

You should add a property to Find form as follows:

Private findTypeValue As FindType
Public Property FindType As FindType
Get
Return findTypeValue
End Get
Set (value as FindType)
findTypeValue = value
End Set

And create Enum for the property:

Public Enum FindType As Integer
Contacts = 0
Users= 1
End Enum

Then in Find form check the type:

If FindType = FindType.Contacts Then
...
Else

End If
Sphynx
A: 

Hi Sphynx thanks for your reply, i ve tried your method, but its working properly, but there may b some problem.

i ve tried using if condition that

If findFormType = findType.contacts Then
            MsgBox("Contacts")
        ElseIf findFormType = findType.users Then
            MsgBox("UserS")
End If

above code is written in Form.vb. now when i press find either from contacts or users msgbox displays Contacts only not Users. More i am not getting your Set & Get Properties. can u tell me how it works, i ve not used earlier. My full code is as below, written in only form.vb...

Public Enum findType As Integer
    contacts = 0
    users = 1
End Enum

Private findTypeValue As findType
Public Property findFormType() As findType
    Get
        Return findTypeValue
    End Get
    Set(ByVal value As findType)
        findTypeValue = value
    End Set
End Property

again thanks for your help

Dhanraj114
Add the Enum to Find.vb, below "End Class" of the form.Add FindType property to Find.vb inside the form classThen set the property upon creation, e.g. as follows:Dim findForm As New FindfindForm.FindType = FindType.UsersfindForm.ShowDialog()
Sphynx