Results 1 to 6 of 6

Thread: Refer to value type of a field on another form

  1. #1

    Thread Starter
    New Member ZoomZero's Avatar
    Join Date
    Mar 2007
    Posts
    14

    Angry Refer to value type of a field on another form

    Hi quite new to VB.2005 and I'm looking for some help please.

    Let me tell what I want to achieve... probably is not the best approach how I'm trying to do but anyway... somebody might guide me.

    I have an MDI form. From the menu I want to load a data bound form (MyDataForm) but before is shown I would like to restrict the records using another form (MyFilterForm) which would give the chance to the users to filter the data form.

    So...
    Code in the MenuItem:
    Code:
     
    Dim F as new MyDataForm
    Dim s as new MyFilterForm
    S.MdiParent=Me
    S.OtherForm = F 'OtherForm is a Form varible on S
    
    S.Show()
    When loading S I need to loop trough all controls on OtherForm(F) to get:
    1.Control name
    2.Control type
    3.Bound control IsValueType property

    On my Filter form (S) the controls for selection will be created at runtime based on the above. I have to create controls with numbers, text, check boxes etc

    I have managed to get 1 and 2 but I do not know how to refer programatically to get 3.
    The ideea is to have form S as stand alone as possible. I could get all this information right at the beginning but I have manny forms using F and copy/paste the same code is not too "elegant".

    I consider that ideally would be to be able to call like this:
    Code:
     
    Dim F as new MyDataForm
    Dim s as new MyFilterForm
    S.MdiParent=Me
    S.OtherForm = F 'OtherForm is a Form varible on S
    S.MyRelevantDataTable= "MyFormDataTable"
    S.Show()
    Then to get point 3, to loop in the 'MyFormDataTable' till I get the collumn and GetType its IsValueType... don't know how to do this.

    Can somebody give a steer please? I'm stuck at this point and searching on different forums but no success.

    Thanks!

  2. #2

    Thread Starter
    New Member ZoomZero's Avatar
    Join Date
    Mar 2007
    Posts
    14

    Arrow [2005] Re: Refer to value type of a field on another form

    Anybody please...

  3. #3

    Thread Starter
    New Member ZoomZero's Avatar
    Join Date
    Mar 2007
    Posts
    14

    Re: Refer to value type of a field on another form

    too hard???

  4. #4
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: Refer to value type of a field on another form

    I am not sure if you are asking how to get the value type but if it is, then you can use the TypeOf keyword to in a condition statment. Since you know all the data types you have you can condition them like this:
    vb Code:
    1. if TypeOf(me) is Form Then
    2.    'do what ever you want
    3. end if

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Refer to value type of a field on another form

    I think you are going about it the wrong way in the first place. THe MDI parent should be creating and loading the MDI Child ONLY.... then in the constructor of the child form, create and show the filter form.

    As for #3, I'm not 100% sure what you mean...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    New Member ZoomZero's Avatar
    Join Date
    Mar 2007
    Posts
    14

    Re: Refer to value type of a field on another form

    Hi

    techgnome - that was the first thing I was dooing but when I was loaded the filter form, the main form was loaded too... this is what I wanted to avoid. If I have started in dialog mode the the filter form was mooving out of the Parent form area... I would like to keep it inside.

    VBDT - What I want to access is the bound field IsValueType of a control on the form I want to filter. I need to set my filter form to validate if the user is trying to enter text in a numeric field. I was able to access if I explicitly specify the data table like:
    Code:
    Me.My_DataSet.MyDataTable.Columns(strColumnName).DataType.IsValueType()
    I need to be able to aceess using the string name of these "My_DataSet", "MyDataTable". Something like

    Code:
    Dim m as New MainForm
    
    If IsTheControlValueType(m,"MyDataSet", 'MyDataTable","AnyColumnName") Then _
              MsgBox "This field is numeric and text is not accepted."
    
    Public Function IsTheControlValueType(f as Form,strDataset as String, strDataTable As String, strFieldName As string) as Boolean 
    
    'I would like to achieve to get this property trough variables f, strDataset, etc. and not in form of:
    'Me.My_DataSet.MyDataTable.Columns(strColumnName).DataType.IsValueType
    End Function
    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width