I have the following code which works fine, however, I want to look up the maximum value in one field of the table
i.e. return the maximum value for field 'ID Count' in table 'thursdaytable'
This code will sit in and excel worksheet rather than in Access.
Can someone help?
Many thanks
Os
i.e. return the maximum value for field 'ID Count' in table 'thursdaytable'
This code will sit in and excel worksheet rather than in Access.
Can someone help?
Many thanks
Os
Code:
Sub DAOFromExcelToAccess()
' exports data from the active worksheet to a table in an Access database
Dim db As Database, rs As Recordset, r As Long
Set db = OpenDatabase("C:\Documents and Settings\Desktop\db1.mdb")
' open the database
Set rs = db.OpenRecordset("thursdaytable", dbOpenTable)
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("oskn1") = Range("a4").Value
.Fields("oskn2") = Range("a5").Value
.Fields("buttonhole") = Range("b6").Value
.Update ' stores the new record
End With
'Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub