Custom Property

dynamictiger

Registered User.
Local time
Today, 14:20
Joined
Feb 3, 2002
Messages
270
I have previously copied examples from Books on custom properties. I am trying to make a custom property for a form.

My aim is to create a generic form that fires on the not in list event of a combo box. I have a module which is working if I pass in the name of the form.

Code:
Function dps_cboNotInList(NewData As String, Response As Integer, strFrmToOpen As String, _
strTable As String, Optional strCBOMessage As String)
Dim blnAddNew As Boolean
'Central Function to handle the not in list event of a combo box
'Arguments:     strFormtoOpen = Form to add data to
'                       NewData = Data from form that was added to list
'                       Response = system generated response
'Optional:        strCBOMessage=custom string to populate the msgbox
'
'Use:                Call dps_cboNotInList(newdata,response,"frmTestUnit")
'OptionalUse:  Call dps_cboNotInList(newData,response,"frmTestUnit","You stuffed it you d....")
'
'The receiving form must have the open args set that if it is greater than 0 then
'the open args populates the matching text box and sets focus further down the form
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    blnAddNew = False

    If Len(strCBOMessage) > 0 Then
    
        If MsgBox(strCBOMessage, vbYesNo + vbQuestion, "Not in List") = vbYes Then
        
            blnAddNew = True
            
        End If
        
    Else
    
        If MsgBox("You have typed an item not in the list.  Add?",  & _
vbYesNo + vbQuestion, "Not in List") = vbYes Then
        
            blnAddNew = True
            
        End If
        
    End If
    
    If blnAddNew Then
           
        DoCmd.OpenForm strFrmToOpen, acNormal, , , acFormAdd, acDialog, OpenArgs:=NewData
        
        Form_frmTestUnit.prpRecord = strTable
        
        If fIsLoaded(strFrmToOpen) Then
        
            Response = acDataErrAdded
            
            DoCmd.Close acForm, strFrmToOpen
            
    Exit Function
            
        Else
        
            MsgBox "Please select an item from the list", vbOKOnly, "Not in List"
            
            Response = acDataErrContinue
            
        End If
        
    Else
    
        MsgBox "Please select an item from the list", vbOKOnly, "Not in List"
    
        Response = acDataErrContinue
        
    End If
  
End Function

I have set Property Get and Property Let statements in the target form as follows:

Code:
Private mvarRecord As Variant
'mVarRecord is the property that tells us what recordsource to use

Property Get prpRecord() As Variant
'Purpose: Retrieve the name of the calling combo box

    prpRecord = mvarRecord
    
End Property
Property Let prpRecord(rvarCBO As Variant)
'Custom property for the calling CBO pass in the table name

    prpRecord = rvarCBO
    
End Property

My thought was to call this property from the open event of the form and use the prpRecord to decide which table to attach my form to as follows:

Code:
Private Sub Form_Open(Cancel As Integer)
'This form is a generic popup for ALL not in list
'events and all single value data entry
'We simply alter the recordsource according to the prpRecord

Dim strCaption As String
Dim strRecordsource As String

    If Len(prpRecord) > 0 Then
    
        Select Case prpRecord
        
        Case Is = "tlkupTestUnit"
        
            strCaption = "Add Test Unit"
        
        End Select
  

    With Me
    
        .Caption = strCaption
        
        .RecordSource = prpRecord
        
    End With
    
    End If
End Sub

What seems to be happening is the code is cycling in the Property Let statement and running out of stack space. I do not properly understand setting my own properties - so I am not sure why this is happening?
 

Users who are viewing this thread

Back
Top Bottom