Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting new values from table 1

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
I am using access 2003. I am trying to write vba code read information from a table. I am almost finished. When using the autonumber datatype I can't figure out how to read the new Values row. This row has two values: Increment and Random. The attributes = 17 for both, the collating order = 1033 for both. I have set up a function for this and all the other properties.
Code:
Function XLFormatNewValues(ByRef D As Field, ByRef Col As String, ByRef lTbl As Integer, ByRef lRow As Integer, ByRef lFld As Integer) As String
Dim dBase As DAO.Database
Set dBase = CurrentDb
Debug.Print Err.Number
On Error Resume Next
'goXL.ActiveSheet.Range(Col & lRow) = dBase.TableDefs(lTbl).Fields(lFld).Properties("NewValues")
goXL.ActiveSheet.Range(Col & lRow) = dBase.TableDefs(lTbl).Fields(lFld).Attributes
goXL.ActiveSheet.Range(Col & lRow) = dBase.TableDefs(lTbl).Fields(lFld).CollatingOrder
'goXL.ActiveSheet.Range(Col & lRow) = dBase.TableDefs(lTbl).Fields(lFld).OriginalValue
goXL.ActiveSheet.Range(Col & lRow) = dBase.TableDefs(lTbl).Fields(lFld).Type
Debug.Print Err.Number
Debug.Print Err.Description
Err.Clear
End Function
 
Is the Size property the same for both ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Is the Type property the same for both ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Type is 4 for both. I just tried properties.Count and both are 15. DefaultValue=GenUniqueID() for both.
 
Try
Code:
Function XLFormatNewValues(D As DAO.Field, Col As String, _
                           lTbl As Integer, lRow As Integer, _
                           lFld As Integer) As String
Dim dBase      As DAO.Database
Set dBase = CurrentDb

With dBase.TableDefs(lTbl).Fields(lFld)
    If .Properties("Autoincrement").Value = TRUE Then
        If Trim$(.Properties("DefaultValue").Value) = "" Then
            goXL.ActiveSheet.Range(Col & lRow) = "Increment"
        Else
            goXL.ActiveSheet.Range(Col & lRow) = "Random"
        End If
    Else
        goXL.ActiveSheet.Range(Col & lRow) = ""
    End If
End With
Set dBase = Nothing
End Function
 
vba317 said:
DefaultValue=GenUniqueID() for both

No it isn't. For an "Increment" type Property DefaultValue is blank and for a "Random" type it is "GenUniqueID()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top