Count CMDButton

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chriscapetrib
    New Member
    • Feb 2007
    • 3

    Count CMDButton

    Hi All
    I need some help.....please !
    I need to use a command button to enter data, - no worries - but i want to use the same button to enter more data(but with different formulas to correspond to the new columns). Is there a way of counting the number of times a command button is pressed?
  • hariharanmca
    Top Contributor
    • Dec 2006
    • 1977

    #2
    Originally posted by chriscapetrib
    Hi All
    I need some help.....please !
    I need to use a command button to enter data, - no worries - but i want to use the same button to enter more data(but with different formulas to correspond to the new columns). Is there a way of counting the number of times a command button is pressed?

    Yes you can use a flag inside command_Click

    Comment

    • chriscapetrib
      New Member
      • Feb 2007
      • 3

      #3
      Originally posted by hariharanmca
      Yes you can use a flag inside command_Click
      Can you please give me an example?

      Comment

      • hariharanmca
        Top Contributor
        • Dec 2006
        • 1977

        #4
        Originally posted by chriscapetrib
        Can you please give me an example?

        Dim intCountClick As Integer

        Private Sub Command1_Click( )
        intCountClick = intCountClick + 1
        Text1.Text = intCountClick
        End Sub

        Private Sub Form_Load()
        intCountClick = 0
        End Sub

        Comment

        • chriscapetrib
          New Member
          • Feb 2007
          • 3

          #5
          Originally posted by hariharanmca
          Dim intCountClick As Integer

          Private Sub Command1_Click( )
          intCountClick = intCountClick + 1
          Text1.Text = intCountClick
          End Sub

          Private Sub Form_Load()
          intCountClick = 0
          End Sub
          I cant seem to get that to work.... thats me, below is the code where i need to count the number of times the command button has been pushed.

          Private Sub cmdAddProcess_C lick()
          Dim RealLastRow As Long
          Dim RealLastColumn As Long

          Range("A1").Sel ect
          RealLastRow = _
          Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
          RealLastColumn = _
          Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Col umn
          Cells(RealLastR ow, RealLastColumn) .Offset(0, 0).Select
          Selection.End(x lToLeft).Offset (0, 1).Select
          ActiveCell.Valu e = Me.txtQty.Value
          ActiveCell.Offs et(0, 1).Select
          ActiveCell.Valu e = Me.Process.Valu e
          ActiveCell.Offs et(0, 1).Select
          ActiveCell.Valu e = "=IF(INDEX('Gla ss-Process'!$A:$A… …….very long
          ActiveCell.Offs et(0, 1).Select
          ActiveCell.Valu e = "=$O$2:$O$1000* IF(INDEX(…….
          Me.txtQty.Value = ""

          End Sub

          Comment

          • hariharanmca
            Top Contributor
            • Dec 2006
            • 1977

            #6
            Dim intCountClick As Integer

            Private Sub Form_Load()
            intCountClick = 0
            End Sub

            Private Sub cmdAddProcess_C lick()
            intCountClick = intCountClick + 1
            Dim RealLastRow As Long
            Dim RealLastColumn As Long

            Range("A1").Sel ect
            RealLastRow = _
            Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
            RealLastColumn = _
            Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Col umn
            Cells(RealLastR ow, RealLastColumn) .Offset(0, 0).Select
            Selection.End(x lToLeft).Offset (0, 1).Select
            ActiveCell.Valu e = Me.txtQty.Value
            ActiveCell.Offs et(0, 1).Select
            ActiveCell.Valu e = Me.Process.Valu e
            ActiveCell.Offs et(0, 1).Select
            ActiveCell.Valu e = "=IF(INDEX('Gla ss-Process'!$A:$A… …….very long
            ActiveCell.Offs et(0, 1).Select
            ActiveCell.Valu e = "=$O$2:$O$1000* IF(INDEX(…….
            Me.txtQty.Value = ""
            End Sub

            Comment

            Working...