Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Red face Unanswered: Making Subform Enable

    I'm creating database to keep track of customer order. I have my main form named "frmCust" and subform "frmOrder. They are both link correct. I would like my subform to be hide or locked until user have enter CustomerNumber in "txtCustNo" in "frmCust".
    Skharva

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    To Lock/UnLock Your SubForm:

    As a default...set the Locked property for your subform frmOrder to Yes. To do this click onto the subform control located on your main form (frmCust} and under the Data tab in the properties window make sure the Locked property is set to "Yes".

    Now in the {b]Lost Focus[/b] event of the txtCustNo textbox enter the following code:
    Code:
    If Not IsNull(Me.txtCustNo) Then
       Me.frmOrder.Locked = False
    Else
       Me.frmOrder.Locked = True
    End If
    To Hide/UnHide your SubForm...Change anything above that states Locked and change it to Visible.

    Because you will be working with many different records, you may want
    to place this code into the frmCust form's On Current event as well.


  3. #3
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Thumbs up

    Originally posted by CyberLynx
    To Lock/UnLock Your SubForm:

    As a default...set the Locked property for your subform frmOrder to Yes. To do this click onto the subform control located on your main form (frmCust} and under the Data tab in the properties window make sure the Locked property is set to "Yes".

    Now in the {b]Lost Focus[/b] event of the txtCustNo textbox enter the following code:
    Code:
    If Not IsNull(Me.txtCustNo) Then
       Me.frmOrder.Locked = False
    Else
       Me.frmOrder.Locked = True
    End If
    To Hide/UnHide your SubForm...Change anything above that states Locked and change it to Visible.

    Because you will be working with many different records, you may want
    to place this code into the frmCust form's On Current event as well.


    Thanks that work very well.

    I also use tab on my main form and have 2 diff subform on tab(2page). When i click on "cmdNew" is it possible that when i'm on page2 and click on "cmdNew" of the Main form it will take me to Page1 with out me changing the tab ?
    Skharva

  4. #4
    Join Date
    Nov 2003
    Posts
    1,487
    In the On Click event for the cmdNew button enter code similar to this:

    Me.myTabControlName.Value = 0

    Where:

    myTabControlName is the actual name of the Tab Control located on your main Form (default is TabCtl0).

    The number supplied (in this case 0) is actualy the tab PageIndex number. By default, the first tab page in a tab control (Page 1) always contains a PageIndex of zero (0), Tab page 2 will then contain a PageIndex number of 1 and so on. You can change the PageIndex numbers to better suit your needs if like. For example, you can change the PageIndex number for each page to represent the actual page number....so...tab page 1 can have a PageIndex number of 1 and tab page 2 can have a PageIndex number of 2 and so on.

    The code line above assumes that the first tab in your Tab Control contains a PageIndex number of zero (0). The PageIndex number can be seen from within the properties window under the Format tab.

    Consequently...if you want to go to the 3rd tab page of your Tab Control, your code would look like:

    Me.myTabControlName.Value = 2


Posting Permissions

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