R
Richard S.
My code has a function to find a record. The function is called by 2
separate search forms, each of which generates SQL for a query that builds a
table of record keys of all qualifying recs. When there is only 1 qualifying
rec, the function is called to open the primary form (Member Data) to the
qualifying rec.
The function uses the rec in the new results table ( a long int ) as the
argument for the FindRecord.
When called by 1 of the forms, it works properly. When called by the second
form it fails on the DoCms.FindRecord line with Runtime error 2162: "A macro
set to 1 of the current fields properties failed because of an error in a
FindRecord action argument."
I don't understand how one can succeed and the other fail, and I don't
really know how to further investigate the problem. Here's the code in the
function:
Public Function FindSingleMbrSearchResult() As Boolean
Dim MbrIDHold As Variant
Dim Result As Boolean
' Open SearchResultInterim recordset having the MbrID of the 1 rec
meeting search criteria
Dim rstSrch As New ADODB.Recordset
rstSrch.Open "SearchResultInterim", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic
' Get MbrID of qualifying rec
rstSrch.MoveFirst
MbrIDHold = rstSrch.Fields("MbrID")
' The following verifies that there is a vailid MbrID in each case
MsgBox "MbrIDHold: " & MbrIDHold
rstSrch.Close
Set rstSrch = Nothing
'Delete rec from SearchResultInterim table
DoCmd.SetWarnings False
DoCmd.OpenQuery "SearchResultInterimDelete"
DoCmd.SetWarnings True
If (VarType(MbrIDHold) > 2) Then
DoCmd.OpenForm "Member Data"
Forms![Member Data]!MbrID.SetFocus
DoCmd.FindRecord MbrIDHold
Result = True
Else
Result = False
End If ' (VarType(MbrIDHold) > 2)
FindSingleMbrSearchResult = Result
End Function
I will greatly appreciate any assistance to understand and correct the problem
separate search forms, each of which generates SQL for a query that builds a
table of record keys of all qualifying recs. When there is only 1 qualifying
rec, the function is called to open the primary form (Member Data) to the
qualifying rec.
The function uses the rec in the new results table ( a long int ) as the
argument for the FindRecord.
When called by 1 of the forms, it works properly. When called by the second
form it fails on the DoCms.FindRecord line with Runtime error 2162: "A macro
set to 1 of the current fields properties failed because of an error in a
FindRecord action argument."
I don't understand how one can succeed and the other fail, and I don't
really know how to further investigate the problem. Here's the code in the
function:
Public Function FindSingleMbrSearchResult() As Boolean
Dim MbrIDHold As Variant
Dim Result As Boolean
' Open SearchResultInterim recordset having the MbrID of the 1 rec
meeting search criteria
Dim rstSrch As New ADODB.Recordset
rstSrch.Open "SearchResultInterim", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic
' Get MbrID of qualifying rec
rstSrch.MoveFirst
MbrIDHold = rstSrch.Fields("MbrID")
' The following verifies that there is a vailid MbrID in each case
MsgBox "MbrIDHold: " & MbrIDHold
rstSrch.Close
Set rstSrch = Nothing
'Delete rec from SearchResultInterim table
DoCmd.SetWarnings False
DoCmd.OpenQuery "SearchResultInterimDelete"
DoCmd.SetWarnings True
If (VarType(MbrIDHold) > 2) Then
DoCmd.OpenForm "Member Data"
Forms![Member Data]!MbrID.SetFocus
DoCmd.FindRecord MbrIDHold
Result = True
Else
Result = False
End If ' (VarType(MbrIDHold) > 2)
FindSingleMbrSearchResult = Result
End Function
I will greatly appreciate any assistance to understand and correct the problem