can't see new customer in control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • barkarlo
    New Member
    • Nov 2006
    • 59

    can't see new customer in control

    I have in form frmworkshop one command button newcustomer.
    When I click him then open frmcustomer and I can write new customer.
    After closed frmcustomer I can't see new customer in control customer on form frmworkshop.
    I must close and open frmworkshop if i want see new customer in control.
    How can I solve this problem.
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    you will need a public function on frmworkshop that you can call from frmcustomer when it closes.

    The code in the public function will simply be
    Code:
    Me.Refresh
    that code will cause the form to refresh and display the new data.
    I am taking it for granted that you know something about VBA here.

    Comment

    • barkarlo
      New Member
      • Nov 2006
      • 59

      #3
      Originally posted by Delerna
      you will need a public function on frmworkshop that you can call from frmcustomer when it closes.

      The code in the public function will simply be
      Code:
      Me.Refresh
      that code will cause the form to refresh and display the new data.
      I am taking it for granted that you know something about VBA here.
      Would you like explain me how can I write public function and where I must put her in form,please.

      Comment

      • Delerna
        Recognized Expert Top Contributor
        • Jan 2008
        • 1134

        #4
        OK
        To get to the code page of the form click the form you want and in the toolbar at the top, click the icon that has a square with a red a green and a yellow dots on it. If you hover over the icon it will say "Code" in the tooltip.

        In the code page for form frmworkshop
        scroll right to the end and paste this code there

        Code:
        Public Sub RefreshTheForm()
           Me.Refresh
           'You may need more code in here to perform other tasks
        End Sub
        you can actually paste the code anywhere on the code page but you must make sure you don't paste it inside another sub.

        Now on the code page for the frmcustomer
        scroll right to the end and paste this code there

        Code:
        Private Sub Form_Unload(Cancel As Integer)
           Forms.frmworkshop.RefreshTheForm()
        End Sub
        Now when frmcustomer unloads (ie closes) it will execute the code in the second code block above. The code there calls the sub in the first code block which refreshes your form

        Not trying to be rude but may I suggest, that if you want to create really good databases, open up the access help documents goto the contents tab and have a look at the visual basic conceptual topics. Try them out and experiment.
        We are always here to help you over any sticky patches, but you need to get some of the basics down for you self and the help files are pretty good for that.

        Comment

        • barkarlo
          New Member
          • Nov 2006
          • 59

          #5
          Originally posted by Delerna
          OK
          To get to the code page of the form click the form you want and in the toolbar at the top, click the icon that has a square with a red a green and a yellow dots on it. If you hover over the icon it will say "Code" in the tooltip.

          In the code page for form frmworkshop
          scroll right to the end and paste this code there

          Code:
          Public Sub RefreshTheForm()
             Me.Refresh
             'You may need more code in here to perform other tasks
          End Sub
          you can actually paste the code anywhere on the code page but you must make sure you don't paste it inside another sub.

          Now on the code page for the frmcustomer
          scroll right to the end and paste this code there

          Code:
          Private Sub Form_Unload(Cancel As Integer)
             Forms.frmworkshop.RefreshTheForm()
          End Sub
          Now when frmcustomer unloads (ie closes) it will execute the code in the second code block above. The code there calls the sub in the first code block which refreshes your form

          Not trying to be rude but may I suggest, that if you want to create really good databases, open up the access help documents goto the contents tab and have a look at the visual basic conceptual topics. Try them out and experiment.
          We are always here to help you over any sticky patches, but you need to get some of the basics down for you self and the help files are pretty good for that.
          when I put you code in frmcustomer return me same error.
          After write Forms. I can put only application, count,Item or parent.
          If I write Forms.frmworksh op.refreshTheFo rm() return me error Expected:=

          Comment

          • Delerna
            Recognized Expert Top Contributor
            • Jan 2008
            • 1134

            #6
            OOPS getting too used to writing java script

            in VBA and VB and VBScript
            Code:
            Forms.frmworkshop.RefreshTheForm()
            is the way to call a function and functions always return a value

            In your case you don't want to return a value, you just want to execute a subroutine, so change it to the following.

            Code:
            Forms!frmworkshop.RefreshTheForm
            Note the absence of the brackets. Also the . changed to !
            The . works but the ! is correct.
            Welcome to the wonderful world of debugging, the act of fixing the silly things that programmers write while not thinking.

            Comment

            Working...