[AccessD] Combobox.oldvalue display text?

Max Wanadoo max.wanadoo at gmail.com
Mon Feb 9 07:43:10 CST 2009


Hi Stuart,
Here are two routines which you may care to look at.  The first is to store
the value into the .TAG property of the control.
The second just parses the controls.
Might be of interes, might not, don't know, submitted as is - chuck it if no
good.
Regards
Max

Public Function pubFunUpdateTagData(frm As Form)
  On Error Resume Next
  ' this puts the data into the tag before any changes are made

  Dim ctl As Control, z As Variant
  For Each ctl In frm.Controls
    With ctl
      Select Case .ControlType
      Case acTextBox  ' this can hold numbers, strings and dates etc
        Select Case varType(frm(ctl.Name))
        Case 2, 3, 4, 5, 6  ' int,long,single,double,currency
          frm(ctl.Name).Tag = Val(frm(ctl.Name))
        Case 7
          frm(ctl.Name).Tag = CStr(frm(ctl.Name))
        Case 8
          frm(ctl.Name).Tag = frm(ctl.Name)
        End Select
      Case acCheckBox
        frm(ctl.Name).Tag = frm(ctl.Name)
      Case acComboBox
        Select Case frm(ctl.Name).RowSourceType
        Case "Table/Query"
          frm(ctl.Name).Tag = Nz(frm(ctl.Name).Column(1))
          'MsgBox frm(ctl.Name).Tag
        Case "Value List"
          frm(ctl.Name).Tag = Nz(frm(ctl.Name).Column(0, 0))
        Case Else
        End Select
      Case acListBox
        frm(ctl.Name).Tag = Nz(frm(ctl.Name).Column(1), "")
      Case acOptionGroup
        frm(ctl.Name).Tag = Nz(frm(ctl.Name), 0)
      End Select
    End With
  Next ctl

exithere:
  Exit Function
errhandler:
  MsgBox "Error in MCM_PeopleChanges.pubFunUpdateTagData: " & Err.Number &
vbCrLf & Err.Description
  Resume exithere
End Function

Private Function RebuildPersonsFlagsFormsControls(frm As Form, lngPID As
Long)
  On Error Resume Next
  Dim ctl As Control, strDesc As String
  Dim varSource As Variant, varvalue As Variant, varType As Variant, varName
As Variant
  Dim varVisible As Variant
  strDesc = frm.Name
  With frm
    For Each ctl In frm.Controls
      varName = ctl.Name
      varType = ctl.ControlType
      Select Case varType
      Case acTextBox
        varSource = ctl.ControlSource
        varvalue = ctl.OldValue
        varVisible = ctl.Visible
        If Not IsNull(varSource) And Len(varSource) > 0 And _
           Not IsNull(varvalue) And Len(varvalue) > 0 And varVisible = True
Then
          Call mcmSetFlag(strDesc & ":" & varSource & ":" & varvalue,
lngPID, conFlagsForms)
        End If
      Case acComboBox
        varSource = ctl.ControlSource
        varvalue = ctl.OldValue
        If Not IsNull(varSource) And Len(varSource) > 0 Then
          Call mcmSetFlag(strDesc & ":" & varSource & ":" & varvalue,
lngPID, conFlagsForms)
        End If
      Case acCheckBox
        varSource = ctl.ControlSource
        varvalue = ctl.OldValue
        If varvalue = True Then
          Call mcmSetFlag(strDesc & ":" & varSource & ":" & varvalue,
lngPID, conFlagsForms)
        End If
      Case acOptionGroup
        varSource = ctl.ControlSource
        varvalue = ctl.OldValue
        Call mcmSetFlag(strDesc & ":" & varSource & ":" & varvalue, lngPID,
conFlagsForms)
      Case acSubform
      Case acLabel
      Case acBoundObjectFrame
      Case acPage
      Case acPageBreak
      Case acCommandButton
      Case acCustomControl
      Case acRectangle
      Case acImage
      Case acTabCtl
      Case acLine
      Case acToggleButton
      Case acObjectFrame
      Case acListBox
      Case acOptionButton
      Case Else
        MsgBox "NewType found in RebuildPersonsFalgsSystemControls:",
varType, varName
      End Select
    Next ctl
  End With
End Function



More information about the AccessD mailing list