
Originally Posted by
NightWalker
@ Moke,
I looked at your code. Could you explain the flow of the code a little. I understand the on click events. I am not understanding all the get and set property code at the bottom of the code and I dont understand the withevents at the top. I really like it and am trying to completely understand it completely.
Not sure I can explain it as I'm still learning alot about them. Its a custom class. The idea is to be able to just drop it into a project and have it work with very little code. Do all the coding up front and then re-use it with very little coding. Its probably a little overkill in this example but it's fun putting it together. As you can see theres no code in the subform. The objects that have withevents are the subform and all its buttons. The withevents just tells the code to listen for events from those objects and passes them to the code to handle them.
I did find one logic error after I posted. Needed to add "Or Me.TheParentForm.NewRecord Then" as shown below.
Code:
Sub m_ctlBNext_Click()
If Me.TheParentForm.Recordset.RecordCount = Me.TheParentForm.CurrentRecord _
Or Me.TheParentForm.NewRecord Then
If Me.CycleFrn = True Then
DoCmd.GoToRecord , Me.TheParentForm.Name, acFirst
Exit Sub
Else
MsgBox "Your at the last record"
Exit Sub
End If
End If
DoCmd.GoToRecord , Me.TheParentForm.Name, acNext
End Sub
If IRC Chip Pearson had a pretty good write up on custom classes. If you google it you should find it.
Same with Withevents.