Error On .LastModified Property

G

Guest

I keep getting an error ("Compile Error: Method or data member not found")
when I compile the following code:

Private Sub CopyRecord_Click()
On Error GoTo Err_CopyRecord_Click

Dim stDocName As String
Dim Query As QueryDef
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("Error Report Table")
DoCmd.SetWarnings False 'Only way I could eliminate a message from a
macro.
DoCmd.Echo False
Me!Department.Visible = True
Me![Error Entered By].Visible = True
stDocName = "CopyToNewRecordQuery"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.SetValue Query![Error Entered By].Value = CurrentUser()
DoCmd.Requery
Me!Department.Visible = False
Me![Error Entered By].Visible = False
rst.Bookmark = rst.LastModifed
DoCmd.SetWarnings True
DoCmd.Echo True

Exit_CopyRecord_Click:
Exit Sub

Err_CopyRecord_Click:
MsgBox Err.Description
Resume Exit_CopyRecord_Click

End Sub

After I click OK, .LastModified is highlighted. Is this a missing reference
problem? If so, what library is this in? I have tried several but I have
been unable to figure out which library will make the above compile error go
away. I have searched through the newsgroups, but have not found anything
that suggests libraries to try. I am extremely new to the world of VBA, and
have had no formal training. Any help would be appreciated.

Thanks,

Tiffany
 
K

Ken Snell [MVP]

DAO library.

Also, I recommend that you change
Dim rst As Recordset

to
Dim rst As DAO.Recordset
 
M

Marshall Barton

TL said:
I keep getting an error ("Compile Error: Method or data member not found")
when I compile the following code:

Private Sub CopyRecord_Click()
On Error GoTo Err_CopyRecord_Click

Dim stDocName As String
Dim Query As QueryDef
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("Error Report Table")
DoCmd.SetWarnings False 'Only way I could eliminate a message from a
macro.
DoCmd.Echo False
Me!Department.Visible = True
Me![Error Entered By].Visible = True
stDocName = "CopyToNewRecordQuery"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.SetValue Query![Error Entered By].Value = CurrentUser()
DoCmd.Requery
Me!Department.Visible = False
Me![Error Entered By].Visible = False
rst.Bookmark = rst.LastModifed
DoCmd.SetWarnings True
DoCmd.Echo True

Exit_CopyRecord_Click:
Exit Sub

Err_CopyRecord_Click:
MsgBox Err.Description
Resume Exit_CopyRecord_Click

End Sub

After I click OK, .LastModified is highlighted. Is this a missing reference
problem? If so, what library is this in? I have tried several but I have
been unable to figure out which library will make the above compile error go
away. I have searched through the newsgroups, but have not found anything
that suggests libraries to try. I am extremely new to the world of VBA, and
have had no formal training. Any help would be appreciated.


In addition to what Ken said, you better move the Echo True
line down after the Exit_CopyRecord_Click label. The way
you have it, your screen is going to lock up whenever your
code encounters any error condition.
 

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