Subform search

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
 
C

craig

CS,
Try this:
Me!Subform1.Form!Subform2.Form!ControlName
or
Me!Subform2.Form!ControlName
--Craig
 
C

CS

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
.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top