Loops and Assignments not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bhughes2187
    New Member
    • Mar 2008
    • 32

    #16
    Originally posted by NeoPa
    I checked the Help for Format Event and I can see no reason why this might happen.

    Can you post just the relevant code in here (the event procedure should do) to check over. If you have any debug (MsgBox() etc) lines then include these and indicate as clearly as you can the output you received.

    PS. Have you had a chance to review my earlier post (#12) yet and might that not answer your original question?

    I have not had a chance to try your suggestion. have to figure out how to impliment it. The number of reports may vary.. which is why I use the recordcount. some clients may only have 2 reports and some may have 8...


    i used the code provided above my not working properly post. i do not have any msgboxs in my current code.. once I saw I was getting the values, I took them out.

    it is this section that isn't working properly

    Code:
      For intCounter = 1 To UBound(rptTitle, 2)
    
          With rstContents
    
            .AddNew
    
              ![Title] = rptTitle(0, intCounter)
    
              ![Page] = Rcount![Total_Count]
    
            .Update
    
          End With
    
        Next

    Comment

    • bhughes2187
      New Member
      • Mar 2008
      • 32

      #17
      Would probably be easier to silently append the data into a table, and then design my report to query off that table and bind the txt boxes to the appropriate fields.

      Comment

      • bhughes2187
        New Member
        • Mar 2008
        • 32

        #18
        OK I AM A MORON!!!


        I didn't realize that the tblcontents was being populated with my data.. Once i designed a query and set my report to display that query, it started working appropriately

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32645

          #19
          Sometimes, all it takes is another look from a different perspective to see what was there all along.

          I was going to comment on the fact that the code seemed to be adding data into a table rather than populating the controls but it seems there's no need.

          Before we stop on this one, are you happy all is ok or do you have any outstanding issues?

          Comment

          • bhughes2187
            New Member
            • Mar 2008
            • 32

            #20
            Originally posted by NeoPa
            Sometimes, all it takes is another look from a different perspective to see what was there all along.

            I was going to comment on the fact that the code seemed to be adding data into a table rather than populating the controls but it seems there's no need.

            Before we stop on this one, are you happy all is ok or do you have any outstanding issues?

            The only thing I would like to do, is if the table is currently populated, to have it delete all the records before repopulating the table..

            This table information is going to change depending on what client and what reports are being run.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32645

              #21
              Well, if the table name is [Titles], you want some SQL like the following :
              [CODE=SQL]DELETE *
              FROM [Titles][/CODE]

              Comment

              • bhughes2187
                New Member
                • Mar 2008
                • 32

                #22
                EDIT!!!

                Nevermind, I figured it out.

                Originally posted by NeoPa
                Well, if the table name is [Titles], you want some SQL like the following :
                [CODE=SQL]DELETE *
                FROM [Titles][/CODE]

                I always get errors putting code in like that..

                I know how to write sql, but I would prefer if a message didn't pop up to let me know I am deleting. I am trying to figure out how to delete using a method similar to the populate method but this stuff now is all new to me

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32645

                  #23
                  Try this :
                  Code:
                  'ClearTable clears the named table.
                  Public Sub ClearTable(strTable As String, Optional strWhere As String = "")
                      Dim strSQL As String
                  
                      On Error GoTo CT_Error
                      strTable = CurrentDb.TableDefs(strTable).Name
                      On Error GoTo 0
                  
                      If strWhere > "" Then strWhere = " WHERE " & strWhere
                      strSQL = Replace("DELETE * FROM [%T]%W;", "%T", strTable)
                      strSQL = Replace(strSQL, "%W", strWhere)
                      Call DoCmd.SetWarnings(False)
                      Call Echo(True, "Running SQL query '" & strSQL & "'.")
                      Call DoCmd.RunSQL(SQLStatement:=strSQL, UseTransaction:=False)
                      Call Echo(True, "SQL query '" & strSQL & "' finished.")
                      Call DoCmd.SetWarnings(True)
                      Exit Sub
                  
                  CT_Error:
                      Call ShowMsg(strMsg:="Invalid table {" & strTable & "}", _
                                   strTitle:="ClearTable")
                  End Sub

                  Comment

                  • bhughes2187
                    New Member
                    • Mar 2008
                    • 32

                    #24
                    Thanks! that worked perfectly...

                    When i have time, I am going to sit down and actually analyze what is actually going on in my program... Hopefully I'll retain some of this stuff

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32645

                      #25
                      No worries :)

                      If you have any questions on it we can certainly help with those.

                      Comment

                      Working...