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_StandardSearchCho ice
Set frmSearchSub = Forms!Contacts!subSearch.F orm
Set frmCalling = Forms(frmSearchSub.Parent. OpenArgs)
Set dynCalling = frmCalling.Recordset.Clone
If VarType(dynCalling(frmCall ing.Tag)) <> vbString Then
dynCalling.FindFirst frmCalling.Tag & " = " & frmSearchSub(frmCalling.Ta g)
Else
dynCalling.FindFirst frmCalling.Tag & " = '" & frmSearchSub(frmCalling.Ta g) & "'"
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_StandardSearchChoi ce:
Exit Function
Error_ap_StandardSearchCho ice:
MsgBox Err.Description, vbCritical, "Search Error"
Resume Exit_ap_StandardSearchChoi ce
End Function
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_StandardSearchCho
Set frmSearchSub = Forms!Contacts!subSearch.F
Set frmCalling = Forms(frmSearchSub.Parent.
Set dynCalling = frmCalling.Recordset.Clone
If VarType(dynCalling(frmCall
dynCalling.FindFirst frmCalling.Tag & " = " & frmSearchSub(frmCalling.Ta
Else
dynCalling.FindFirst frmCalling.Tag & " = '" & frmSearchSub(frmCalling.Ta
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_StandardSearchChoi
Exit Function
Error_ap_StandardSearchCho
MsgBox Err.Description, vbCritical, "Search Error"
Resume Exit_ap_StandardSearchChoi
End Function
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.
ASKER
I get the error on this line:
dynCalling.FindFirst frmCalling.Tag & " = " & frmSearchSub(frmCalling.Ta g)
dynCalling.FindFirst frmCalling.Tag & " = " & frmSearchSub(frmCalling.Ta
>frmSearchSub(frmCalling.T ag)
If frmCalling is a subform within subSearch?
If frmCalling is a subform within subSearch?
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.
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
dynCalling.FindFirst frmCalling.Tag & " = " & [frmCalling].[Form].Tag
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.