My Trial Switchboard problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cephal0n
    New Member
    • Jan 2008
    • 38

    My Trial Switchboard problem

    I have a main table with a unique id, name tblMain this is where I get my unqID, I also made another table named tblClone using the SELECT Update. I have two forms Form1,Form2, 1 command button and textbox named txtTotal. My Form1 is used as a switchboard for my Form2.

    in my Form2 I put my textbox and set Me.txtTotal= DCount("[unqID]","[tblClone]") and

    in my Command1 I put my command1 button and set Me.Visible=Fals e to close my switchboard and
    DoCmd.OpenForm "Form2", acNormal

    my problem is, every time I click my command1 button to show Form2.My txtTotal shows 0 value. I don’t understand it because vba doesn’t show any error during runtime and when I switched to design view and manually open my Form2. this is the only time my Form2 shows the correct value counted.

    How can I make my txtTotal to show my total value when I clicked my commnd1 button from Form1? Is my switchboard the problem? Please help
  • patjones
    Recognized Expert Contributor
    • Jun 2007
    • 931

    #2
    Originally posted by cephal0n
    I have a main table with a unique id, name tblMain this is where I get my unqID, I also made another table named tblClone using the SELECT Update. I have two forms Form1,Form2, 1 command button and textbox named txtTotal. My Form1 is used as a switchboard for my Form2.

    in my Form2 I put my textbox and set Me.txtTotal= DCount("[unqID]","[tblClone]") and

    in my Command1 I put my command1 button and set Me.Visible=Fals e to close my switchboard and
    DoCmd.OpenForm "Form2", acNormal

    my problem is, every time I click my command1 button to show Form2.My txtTotal shows 0 value. I don’t understand it because vba doesn’t show any error during runtime and when I switched to design view and manually open my Form2. this is the only time my Form2 shows the correct value counted.

    How can I make my txtTotal to show my total value when I clicked my commnd1 button from Form1? Is my switchboard the problem? Please help
    Hi:

    What event for Form2 did you put the text box assignment in? If you can post the code that you're using that would be great.

    Pat

    Comment

    • cephal0n
      New Member
      • Jan 2008
      • 38

      #3
      I hope I get what you ask. this is where I assigned my txtClone.
      Code:
      Private Sub Form_Load()
      Me.txtToatl=DCount("[UnqID]","[tblClone]")
      
      End Sub
      thanks for replying!
      Last edited by NeoPa; May 22 '08, 12:52 PM. Reason: [CODE] tags

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32661

        #4
        Please remember to use the [ CODE ] tags in future. Congratulations on reaching full member status btw :), but we do expect our members to remember this in their posts ;)

        Anyway, first things first. Are you aware that the code you posted misspells txtTotal? This may be as it is set up in your database of course. Either way it's a bad sign. Attention to detail is fundamental to working with databases. This could actually be why it's failing.

        Do you enforce variable declaration in your code?

        Comment

        • patjones
          Recognized Expert Contributor
          • Jun 2007
          • 931

          #5
          Originally posted by NeoPa
          Anyway, first things first. Are you aware that the code you posted misspells txtTotal? This may be as it is set up in your database of course. Either way it's a bad sign. Attention to detail is fundamental to working with databases. This could actually be why it's failing.
          But cephal0n says that it shows the correct value when he opens the form manually. I wondered if it had something to do with using Form Load instead of Form Open, so I made a little test db and used Form Load. I found that it doesn't matter whether I open the form manually, or open it by clicking on the command button in the first form.

          cephal0n, you are running the DCount off "tblClone", which you say comes from a SELECT Update. Does this mean that it's a temporary table that comes into existence only when Form 2 opens?

          Pat

          Comment

          • cephal0n
            New Member
            • Jan 2008
            • 38

            #6
            Hi everyone!

            I apologize for the delay I was still trying out INSERT INTO sql instead of SELECT UPDATE and still getting the same results. Before I go on I would like to thank you guys for replying to my question. I was hoping this will be a simple question with simple answer, but I guess not.

            About the question
            Do you enforce variable declaration in your code?

            I really don’t want to make it complicated I just want to show the results first before going to my next procedure.

            And about the question
            cephal0n, you are running the DCount off "tblClone", which you say comes from a SELECT Update. Does this mean that it's a temporary table that comes into existence only when Form 2 opens?

            yes, my table tblClone only comes into existence if my Form2 is called. My main source table tblMain can change data anytime and can contain 500 or more Items, so every time changes are made, so will my tblClone's data changes as well and this is where I usually do my computations and more.

            I hope I answered your questions and Thanks in advanced!

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32661

              #7
              Originally posted by cephal0n
              ...
              About the question
              Do you enforce variable declaration in your code?

              I really don’t want to make it complicated I just want to show the results first before going to my next procedure.
              ...
              I read this a number of times without understanding what you're trying to say.

              Do you mean worrying about such trivial things as Variable Declaration would complicate things?

              I want to assume not, as that would tough to reply to. I will restrict myself to saying that would be so wrong.

              Comment

              Working...