waipahunet
Registered User.
- Local time
- Today, 21:57
- 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!
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!