Subform search

  • Thread starter Thread starter CS
  • Start date Start date
C

CS

The following Find Record code works fine when it's from a
standalone form but when it is from a subform I get the
error that the field 'ME_ID' does not exist. I'm thinking
that it's the form/subform reference but I don't know the
syntax. I appreciate any help with this problem, thanks.
-------------------------------------------
Dim strSampleRef As String
Dim strSearch As String

'Check txtSearch for Null value or Null Entry first.

If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search
Criterion!"
Me![txtSearch].SetFocus
Exit Sub
End If
'Performs the search using value entered into txtSearch
and evaluates this against values in strSampleRef

DoCmd.ShowAllRecords
DoCmd.GoToControl ("ME_ID")
DoCmd.FindRecord Me!txtSearch

ME_ID.SetFocus
strSampleRef = ME_ID.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
 
CS,
Try this:
Me!Subform1.Form!Subform2.Form!ControlName
or
Me!Subform2.Form!ControlName
--Craig
 
Thanks for the suggestion Craig but I still can't get it
to work for me (Run Time error 2465). Any other
suggestions?
-----Original Message-----
CS,
Try this:
Me!Subform1.Form!Subform2.Form!ControlName
or
Me!Subform2.Form!ControlName
--Craig
-----Original Message-----
The following Find Record code works fine when it's from a
standalone form but when it is from a subform I get the
error that the field 'ME_ID' does not exist. I'm thinking
that it's the form/subform reference but I don't know the
syntax. I appreciate any help with this problem, thanks.
-------------------------------------------
Dim strSampleRef As String
Dim strSearch As String

'Check txtSearch for Null value or Null Entry first.

If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search
Criterion!"
Me![txtSearch].SetFocus
Exit Sub
End If
'Performs the search using value entered into txtSearch
and evaluates this against values in strSampleRef

DoCmd.ShowAllRecords
DoCmd.GoToControl ("ME_ID")
DoCmd.FindRecord Me!txtSearch

ME_ID.SetFocus
strSampleRef = ME_ID.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
.
.
 
Back
Top