dim db as Database

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.
 
D

Douglas J. Steele

It could be a problem with your References collection. These can occur if
you install new software.

Go into the VB Editor and select Tools | References from the menu bar.

Examine all of the selected references (the ones with the check marks at the
top of the list)

If any of the selected references have "MISSING:" in front of them, unselect
them and back out of the dialog (Make sure you write down what the
references were before you delete them, because they'll be in a different
order once they're unselected).

If you need the reference(s) you just unselected (you can tell by doing a
Compile, under the Debug menu), go back in and reselect them.

If none have "MISSING:" in front of them, select an additional reference at
random, back out of the dialog, then go back in and unselect the refernece
you just added. If that doesn't solve the problem, try to unselect as many
of the selected references as you can (Access won't let you unselect them
all), back ouf of the dialog, then go back in and reselect the references
you just unselected.
 
L

lumpy04

THanks Doug. I checked the references and found one missing: Microsoft DAO
3.6 Object Library

I( de-selected like you suggested and backed. Tried to compile he project
and got the same error. I checked the references again and Microsoft DAO 3.6
Object Library is no longer listed as an option.

Can I import this library somehow?
 
D

Douglas J. Steele

You shouldn't need to import it. You scrolled through the list and couldn't
find it?

The specific file should be C:\Program Files\Common Files\Microsoft
Shared\DAO\dao360.dll

Assuming it's there, you could try reregistering it using regsvr32.exe. See
http://support.microsoft.com/?kbid=161983 for details.
 
L

lumpy04

Thank you!

I ws able to reload the missing DLL using the path you gave me. My
spreadsheet works again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top