Duplicate the Record in a Form and many SubForms

M

Martin

I am using Allen Browne's tip that is available in his web site. However, I
get a compile error stating that the variable dbFailOnError is not defined. I
have search the MS Knowdledgeable base and found out the DBEngine (0)
(0).Execute is no longer used in current versions. I change it to the
following but I still get the same compile error message.

If Me.SF_Adjacencies.Form.RecordsetClone.RecordCount > 0 Then
strSql = "INSERT INTO [Adjacencies] ( DataRmID, AdjID,_
AdjRoomName, AdjRelevance ) " & _
"SELECT " & lngID & " As NewID, AdjID, AdjRoomName,_
AdjRelevance " & _
"FROM [Adjacencies] WHERE DataRmID = " & Me.DataRmID & ";"
CurrentDb().Execute strSql, dbFailOnError
Else
MsgBox "Main record duplicated, but there were no related
records."
End If

I have tried also adding
DIM dbs As DAO.Database
Set dbs=CurrentDB()

and substitute the line...
dbs.Execute strSQL, dbFailOnError

but the code will stop at DAO.Datase stating a compile error of User-Defined
type not defined.

Thank you.
 
M

Martin

You are correct. The library was not registered.

Thanks

Allen Browne said:
Sounds like you need to add a reference to the DAO library.

For details, see:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Martin said:
I am using Allen Browne's tip that is available in his web site. However, I
get a compile error stating that the variable dbFailOnError is not
defined. I
have search the MS Knowdledgeable base and found out the DBEngine (0)
(0).Execute is no longer used in current versions. I change it to the
following but I still get the same compile error message.

If Me.SF_Adjacencies.Form.RecordsetClone.RecordCount > 0 Then
strSql = "INSERT INTO [Adjacencies] ( DataRmID, AdjID,_
AdjRoomName, AdjRelevance ) " & _
"SELECT " & lngID & " As NewID, AdjID, AdjRoomName,_
AdjRelevance " & _
"FROM [Adjacencies] WHERE DataRmID = " & Me.DataRmID &
";"
CurrentDb().Execute strSql, dbFailOnError
Else
MsgBox "Main record duplicated, but there were no related
records."
End If

I have tried also adding
DIM dbs As DAO.Database
Set dbs=CurrentDB()

and substitute the line...
dbs.Execute strSQL, dbFailOnError

but the code will stop at DAO.Datase stating a compile error of
User-Defined
type not defined.

Thank you.
 

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