Problem - Duplicate Form and subform record

waipahunet

Registered User.
Local time
Today, 15:14
Joined
Oct 13, 2003
Messages
20
Could someone help me figure out what's wrong with the follow code? The debug highlights the following as the problem: "Complie Error: User-defined type not defined" and then highlights the following: Dim dbs As Database Any suggestions would be greatly appreciated. Below is the code:

Private Sub btnDuplicate_Click()
Dim dbs As DAO.Database, Rst As DAO.Recordset
Dim F As Form

' Return Database variable pointing to current database.
Set dbs = CurrentDb
Set Rst = Me.RcordsetClone

On Error GoTo Err_btnDpulicate_Click

' Tag property to be used later by the append query.
Me.Tag = Me![PromoID]

' Add new record to end of Recordset object.
With Rst
.AddNew
!fiscalyear = Me!fiscalyear
!PrincipalCode = Me!PrincipalCode
!CustomerCode = Me!CustomerCode
!PromoStatus = Me!PromoStatus
!SalesPerson = Me!SalesPerson
!PrincipalAuth = Me!PrincipalAuth
!Comments = Me!Comments
.Update ' Save changes.
.Move 0, .LastModified
End With
Me.Bookmark = Rst.Bookmark

' Run the Duplicate Promo Details append query which selects all
' detail records that have the PromoID stored in teh form's
' Tag property and appends them back to teh detail table with
' the PromoID of teh duplicated main form record.

DoCmd.SetWarnings Fals
DoCmd.OpenQuery "Duplicate Promo Details"
DoCmd.SetWarnings True

' Requery the subform to display teh newly append records.
Me![frm_promodetail_sf].Requery

Exit_btnduplicate_Click:
Exit Sub

Err_btnDuplicate_Click:
MsgBox Error$
Resume Exit_btnduplicate_Click:
End Sub

I followed the example posted on the MS site http://support.microsoft.com/default.aspx?scid=kb;en-us;208824&product=acc It worked when I tried it on the Northwind sample database but not on my other database.

Thanks!
 
ok, I'm starting to think that this topic should be in MS's FAQ's on Access (if they have one). You need to set a Reference to the DAO 3.5 or above Object Library. Open a Module, go to Tools->References->Microsoft 3.5 Object Library.
 
almost there

Thanks for the reply. The instructions said to select Microsoft DAO 3.6 Object Library but when I chose the 3.5 it didn't give me that error. The issue now is that it didn't copy the records in the subform. I'm went throuh each line of code and compare to the Northwind and other than the [Tag] variable and subform name, everything is the same. Any suggestions? Thanks again!
 

Users who are viewing this thread

Back
Top Bottom