Database fault

C

Cameron

I keep getting an error on a Dim statement saying that the word "database" is
a unknown user defined function. I am working on this database as the orginal
developer died and I am kind of baffled by certain database calls do not work
with it. The code I have under a click event is as follows:

Private Sub MoveToER_Click()
On Error GoTo Err_MoveToER_Click
Dim MyDB As DATABASE
Dim MyStudents As Recordset
Dim i, X As Integer

Set MyDB = CurrentDb
Set MyStudents = MyDB.OpenRecordset("SS_errors", dbOpenTable)
DoCmd.Hourglass True

For i = 0 To Me.lstErrors.ListCount
If Me.lstErrors.Selected(i) = True Then
With MyStudents
.AddNew
!SS_ErrorID = Me.SafeStart_number
!SS_errors = Me.lstSSers 'saves the errors in the
errors table. Need to have an ID assocated with the current record.
.Update
End With
End If
Next i

MyStudents.Close
MyDB.Close
Set MyDB = Nothing
Form.Refresh
DoCmd.Hourglass False



Err_MoveToER_Click:
MsgBox Err.Description
'Resume Exit_MoveToER_Click

End Sub
 
K

Klatuu

Try identifying the database type
Use either
Dim MyDb as ADO.Database
or
Dim MyDb as ADO.Database

depending on which you are using. If neither works, you are missing one or
more library references. In the VBA editor, Tools, References.
If you find any that are missing, try relinking the reference from the list
of available references. If none are identified as missing, look for the ADO
or DAO references and link them.
 
C

Cameron

I found the ADO and DAO references where not in the list and linked them. but
I keep getting an type miss match error now. But the compiler sees the
database keyword as being legit.
 
C

Cameron

ok, I fixed that. But now I get a mesage box with no error. Hum, maybe i have
the references in the wrong order...
 
C

Cameron

Ok, I can do that too.

As far as I can tell this database did not have any kind of transfer
protocol defined. No where in the code do I see any requests to open or close
databases, nor is there any kind of security. Hum, think i have my work cut
out for me.
 
R

Rick Brandt

Klatuu said:
Still a good idea to define the database type

Pretty sure DAO is the only one that has a database. There are a handful of
objects that have the same names between ADO and DAO, but database is not one of
them.
 
K

Klatuu

Is your database split?
If you are using a normal configuration of a front end mdb or mde, and a
back end mdb or if you are doing the horrible offensive unsplit database
where the data and the application are in the same mdb, you wont see any
database opens or any protocols. Even with a properly spilt application, the
front end knows where the data is and links to it. It is much more
simplistic than most database engines.

As to security, I wouldn't bother. Access security is pretty weak. A
knowledgable person can crack it in seconds with free or inexpensive software
that can be downloaded from the web.
 
U

UpRider

Cameron if you're still getting the msgbox with no error, look at your code.
It always drops down into your error routine, even with no error.
Change it like this:

Next i
Exit_MoveToER_Click:
MyStudents.Close
MyDB.Close
Set MyDB = Nothing
Form.Refresh
DoCmd.Hourglass False
Exit Sub
Err_MoveToER_Click:
MsgBox Err.Description
Resume Exit_MoveToER_Click
End Sub

HTH, UpRider
 

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