Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    5

    Unhappy Unanswered: Field property in Access

    Hi,
    I'm trying to rearrange the columns in a table in access and I have the following code, but it keep telling me i have "complied error" Member or data member not found at the "Set fld=tdf.field("billperiod") line.
    I have the DAO 3.6 reference installed already.
    is there another way of rearranging columns in VB? please help


    Sub test()
    Dim db As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field

    Set db = CurrentDb
    Set tdf = db.TableDefs("table2")

    Set fld = tdf.Field("Billperiod")

    SetFieldProperty fld, "columnorder", dbLong, 2
    End Sub


    Public Sub SetFieldProperty(ByVal fld As DAO.Field, ByVal strPropertyName As String, ByVal iDataType As Integer, ByVal vValue As Variant)

    Dim prp As DAO.Property

    Set prp = Nothing

    On Error Resume Next
    Set prp = fld.Properties(strPropertyName)
    On Error GoTo 0

    If prp Is Nothing Then
    Set prp = fld.CreateProperty(strPropertyName, iDataType, vValue)
    fld.Properties.Append prp
    Else: prp.Value = vValue
    End If
    End Sub

  2. #2
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Smile Re: Field property in Access

    Originally posted by Twinki
    Hi,
    I'm trying to rearrange the columns in a table in access and I have the following code, but it keep telling me i have "complied error" Member or data member not found at the "Set fld=tdf.field("billperiod") line.
    I have the DAO 3.6 reference installed already.
    is there another way of rearranging columns in VB? please help


    Sub test()
    Dim db As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field

    Set db = CurrentDb
    Set tdf = db.TableDefs("table2")

    Set fld = tdf.Field("Billperiod")

    SetFieldProperty fld, "columnorder", dbLong, 2
    End Sub


    Public Sub SetFieldProperty(ByVal fld As DAO.Field, ByVal strPropertyName As String, ByVal iDataType As Integer, ByVal vValue As Variant)

    Dim prp As DAO.Property

    Set prp = Nothing

    On Error Resume Next
    Set prp = fld.Properties(strPropertyName)
    On Error GoTo 0

    If prp Is Nothing Then
    Set prp = fld.CreateProperty(strPropertyName, iDataType, vValue)
    fld.Properties.Append prp
    Else: prp.Value = vValue
    End If
    End Sub

    Try:
    Set fld = tdf.Fields("Billperiod")

    Instead of:
    Set fld = tdf.Field("Billperiod")

    Your dealing with the fields collection of the tabledef object.

    Hope it works.

    Gregg

  3. #3
    Join Date
    Oct 2003
    Posts
    5

    Rearranging columns in Access

    thank you, the error message is gone but the order of the column didn't change?

Posting Permissions

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