Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Location
    Australia
    Posts
    217

    Question Unanswered: VB6 - Data Grid and Format

    (1) Why the data grid's REFRESH method doesn't refresh the grid ??

    (2) How can I set data format for text boxes, e.g. Date, Number, Text, etc. ?? (We can do this easily in MS Access via the Format property)

    Thank you in advance.

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Quote Originally Posted by Lepanto
    (1) Why the data grid's REFRESH method doesn't refresh the grid ??

    (2) How can I set data format for text boxes, e.g. Date, Number, Text, etc. ?? (We can do this easily in MS Access via the Format property)

    Thank you in advance.
    To refresh the DATA in the grid, requery the recordset, then rebind the grid.

    To change the column formatting, ref this thread at a sister site.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    Jul 2003
    Location
    Australia
    Posts
    217
    Thanks. But the second question concerns text box, not data grid.

    Is it doable ?

  4. #4
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Quote Originally Posted by Lepanto
    Thanks. But the second question concerns text box, not data grid.

    Is it doable ?
    Only by formatting the text you place into the textbox. There is no built-in format capability for the textbox.

    Code:
    Me.Text1.Text = Format(Now(), "mm-dd-yyyy hh:nn")
    You could emulate this (to a certain extent) by poking the format string into the .tag property of the textbox, and adding a timer with a quarter second interval.

    Code:
    Sub Timer1_Timer()
      Dim ctrl as control
    
      for each ctrl in Me
        If TypeOf ctrl is TextBox then
          if trim(ctrl.Tag) <> "" then
            ctrl.Text = Format(ctrl.Text, ctrl.Tag)
            ctrl.tag = ""
          end If
        End If
      Next ctrl
    
    End Sub
    Last edited by loquin; 04-23-07 at 19:54.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

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