Link to home
Start Free TrialLog in
Avatar of Leo_Nel
Leo_Nel

asked on

Method or data Member not found

When I run the following I receive a Compile Error: Method or  data Member not found

Can any help point out my mistake?

Public Function ap_StandardSearchChoice()
      Dim frmCalling As Form
      Dim frmSearchSub As Form
      Dim dynCalling As Recordset
     
      On Error GoTo Error_ap_StandardSearchChoice
     
      Set frmSearchSub = Forms!Contacts!subSearch.Form
      Set frmCalling = Forms(frmSearchSub.Parent.OpenArgs)
      Set dynCalling = frmCalling.Recordset.Clone
     
      If VarType(dynCalling(frmCalling.Tag)) <> vbString Then
        dynCalling.FindFirst frmCalling.Tag & " = " & frmSearchSub(frmCalling.Tag)
      Else
        dynCalling.FindFirst frmCalling.Tag & " = '" & frmSearchSub(frmCalling.Tag) & "'"
      End If
   
      If dynCalling.NoMatch Then
        MsgBox "An Error has occurred, No match record found!", 32, "Search Error!"
      Else
        frmCalling.Bookmark = dynCalling.Bookmark
      End If
   
      dynCalling.Close
   
      DoCmd.Close acForm, "Contacts"

Exit_ap_StandardSearchChoice:
    Exit Function

Error_ap_StandardSearchChoice:

    MsgBox Err.Description, vbCritical, "Search Error"
    Resume Exit_ap_StandardSearchChoice

End Function
Avatar of Lucas
Lucas
Flag of Canada image

on which line you get the errer?
disable your error handler and debug it, that would be easier
Go to the Debug menu, Compile function, and when you get an error message tell us which line has the yellow highlight bar.
Avatar of Leo_Nel
Leo_Nel

ASKER

I get the error on this line:

 dynCalling.FindFirst frmCalling.Tag & " = " & frmSearchSub(frmCalling.Tag)
>frmSearchSub(frmCalling.Tag)
If frmCalling is a subform within subSearch?
Avatar of Leo_Nel

ASKER

Yes, there is a SubForm.
Is this function in a standard module?  If so, you have to put code in there to make sure that the main form and subform are open in order for you to access the values of the controls.

If you are certain that both forms are open when this function is executed,  then make sure that frmCalling.Tag contains a valid name of a control in the subform.
I think you aren't correctly addressing the Tag control in your subform.  this assumes there is a control on your subform named Tag.

dynCalling.FindFirst frmCalling.Tag & " = " & [frmCalling].[Form].Tag
ASKER CERTIFIED SOLUTION
Avatar of stevbe
stevbe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial