L
lumpy04
Hello,
I use an excel sheet to send data to an MS Access table. Basically, I fill
the form out and it sends the data from specific cells to an access database
when I click "submit". It has been working fine for almost a year. Now i get
an error that the database can not be located, and when I open the code the
line "dim db as database" is highlited. The data base has not moved.
' exports data from the active worksheet to a table in an Access database
'(\\usshl2-dplfsd01\data$\Documentation\PC Build Records.mdb)
' this procedure must be edited before use
Dim db As Database, rs As Recordset, r As Long
Set db = OpenDatabase("\\usshl2-dplfsd01\data$\Documentation\PC Build
Records.mdb")
' open the database
Set rs = db.OpenRecordset("Build Records", dbOpenTable)
' get all records in a table
'r = 1 ' the start row in the worksheet
'Do While Len(Range("A" & r).Formula) > 0
' repeat until first empty cell in column A
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("Date of Build") = Range("B1").Value
.Fields("User Name") = Range("B2").Value
.Fields("Image Used") = Range("B3").Value
.Fields("Project") = Range("B4").Value
.Fields("Operating System") = Range("B5").Value
.Fields("Device Type") = Range("B6").Value
.Fields("Service Tag") = Range("B7").Value
.Fields("warranty") = Range("b8").Value
' add more fields if necessary...
.Update ' stores the new record
End With
' r = r + 1 ' next row
'Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
I copied this code from the internet, so don't ask me for an indepth
explanation.
I read som posts about the difference between DAO and ADO libraries, but I
don't know enough to follow up on that.
I use an excel sheet to send data to an MS Access table. Basically, I fill
the form out and it sends the data from specific cells to an access database
when I click "submit". It has been working fine for almost a year. Now i get
an error that the database can not be located, and when I open the code the
line "dim db as database" is highlited. The data base has not moved.
' exports data from the active worksheet to a table in an Access database
'(\\usshl2-dplfsd01\data$\Documentation\PC Build Records.mdb)
' this procedure must be edited before use
Dim db As Database, rs As Recordset, r As Long
Set db = OpenDatabase("\\usshl2-dplfsd01\data$\Documentation\PC Build
Records.mdb")
' open the database
Set rs = db.OpenRecordset("Build Records", dbOpenTable)
' get all records in a table
'r = 1 ' the start row in the worksheet
'Do While Len(Range("A" & r).Formula) > 0
' repeat until first empty cell in column A
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("Date of Build") = Range("B1").Value
.Fields("User Name") = Range("B2").Value
.Fields("Image Used") = Range("B3").Value
.Fields("Project") = Range("B4").Value
.Fields("Operating System") = Range("B5").Value
.Fields("Device Type") = Range("B6").Value
.Fields("Service Tag") = Range("B7").Value
.Fields("warranty") = Range("b8").Value
' add more fields if necessary...
.Update ' stores the new record
End With
' r = r + 1 ' next row
'Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
I copied this code from the internet, so don't ask me for an indepth
explanation.
I read som posts about the difference between DAO and ADO libraries, but I
don't know enough to follow up on that.