UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Find First Id On Continuous Sub Form, Access 2013    
 
   
aburl81
post May 15 2018, 07:32 PM
Post#1



Posts: 396
Joined: 24-February 06
From: Corona, CA


Hi UA,

having some trouble with findfirst. I have a main form with a subform on it. main goal to have a popup form with an option group and place that selection in a control on the subform. Text23 holds a copy of the test_id for the record that I want to return to. Text 18 & 14 hold info to be placed into the test_result control on sfrm_lab. Been working at this awhile, please let me know if that doesn't make any sense.

CODE
Dim strCriteria As String
Dim rst As DAO.Recordset

' Define search criteria
strCriteria = Forms!frm_treatDetails!sfrm_lab.Form!test_id & Forms!frm_treatDetails!sfrm_lab.Form!Text23 & "'"

Set rst = Forms!frm_treatDetails!sfrm_lab.Form.RecordsetClone

' Find the first occurrence
rst.FindFirst strCriteria

If rst.NoMatch Then
  MsgBox "No match found"
Else
  ' Move to the record on the subform
  Forms!frm_treatDetails!sfrm_lab.Form.Bookmark = rst.Bookmark
  
  Forms!frm_treatDetails!sfrm_lab.Form!test_result = Me.Text18 & " " & Me.Text14
End If
Go to the top of the page
 
theDBguy
post May 15 2018, 08:07 PM
Post#2


Access Wiki and Forums Moderator
Posts: 73,508
Joined: 19-June 07
From: SunnySandyEggo


Hi Adan,

Your criteria seems a bit off. If you do a Debug.Print strCriteria, does it look correct?
Go to the top of the page
 
aburl81
post May 15 2018, 09:51 PM
Post#3



Posts: 396
Joined: 24-February 06
From: Corona, CA


Thank you DBGuy,

found the problem in the criteria but now im getting an invalid argument at the findfirst.

updated criteria:
strCriteria = Forms!frm_treatDetails!sfrm_lab.Form!test_id & Forms!frm_treatDetails!sfrm_lab.Form!Text23
Go to the top of the page
 
theDBguy
post May 15 2018, 10:10 PM
Post#4


Access Wiki and Forums Moderator
Posts: 73,508
Joined: 19-June 07
From: SunnySandyEggo


FindFirst requires a String for an argument. What does your strCriteria contains?

In other words, what does the Debug.Print result look like?
Go to the top of the page
 
aburl81
post May 15 2018, 10:12 PM
Post#5



Posts: 396
Joined: 24-February 06
From: Corona, CA


The debug print shows the stored id like 174. Is there a better way to get back to the record that I started from?
This post has been edited by aburl81: May 15 2018, 10:15 PM
Go to the top of the page
 
theDBguy
post May 15 2018, 10:18 PM
Post#6


Access Wiki and Forums Moderator
Posts: 73,508
Joined: 19-June 07
From: SunnySandyEggo


Okay, you're strCriteria should end up with something more like:

"ID=174"

Is that what you got?
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    22nd October 2018 - 12:31 PM