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

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V < 1 2  (Go to first unread post)
   Reply to this topicStart new topic
> Link From Report To Subform, Access 2016    
 
   
Jackerman
post Jan 16 2020, 03:36 PM
Post#21



Posts: 13
Joined: 6-January 20



In my .FindFirst statement the strCriteria needs to be defined as an integer since it is based on the subform ID. I cant get the strCriteria to Dim As Integer. I keep falling into a loop of data and type mismatches...any words of wisdom?
Go to the top of the page
 
Jackerman
post Jan 16 2020, 03:41 PM
Post#22



Posts: 13
Joined: 6-January 20



Here is the code as it sits currently.

Dim strWhere As String
Dim DocName As String
DocName = "LiveJobs"
strWhere = "[Job Number]=" & "'" & Me![Job Number] & "'"
DoCmd.OpenForm DocName, acNormal, , strWhere
Forms![LiveJobs].[Estimate Items Subform].SetFocus

'find the Item in the item subform

Dim db As DAO.Database
Dim RstItem As DAO.Recordset
Dim strItemCriteria As Integer
strItemCriteria = [Estimate Item subform table ID] = "Me![Estimate Item subform table ID]"
Set db = CurrentDb
Set RstItem = db.OpenRecordset("Estimate Items Subform table", dbOpenDynaset, dbSeeChanges)
With RstItem
RstItem.FindFirst strItemCriteria
End With


Go to the top of the page
 
theDBguy
post Jan 16 2020, 03:55 PM
Post#23


UA Moderator
Posts: 77,481
Joined: 19-June 07
From: SunnySandyEggo


Hi. It might be more helpful if you could post a sample db for testing, so we can see what's actually happening. Is that possible?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Jackerman
post Jan 17 2020, 02:26 PM
Post#24



Posts: 13
Joined: 6-January 20



I am a bit reluctant to post the database which I know poses an issue. I think I have the code written correctly but it will not go to the record as I want it to. When I am in debug and hover over the strCriteria and other code it all seems to be finding and doing what it is supposed to but wont go to the record based on the criteria. It will find the 'Job Number' and go to the correct Job but will not find the correct 'Estimate Item Subform table ID' and go to that. Here is the code:

Private Sub Estimated_hours_for_current_week_Click()

Dim strWhere As String
Dim DocName As String
DocName = "LiveJobs"
strWhere = "[Job Number]=" & "'" & Me![Job Number] & "'"
DoCmd.OpenForm DocName, acNormal, , strWhere
Forms![LiveJobs].[Estimate Items Subform].SetFocus
'find the Item in the item subform
Dim dbs As DAO.Database
Dim RstItem As DAO.Recordset
Dim strItemCriteria As String
Set dbs = CurrentDb
Set RstItem = dbs.OpenRecordset("Estimate Items Subform table", dbOpenDynaset)
strItemCriteria = ([Estimate Item subform table ID] = Me.Estimate_Item_subform_table_ID)
With RstItem
RstItem.MoveLast
DoEvents
RstItem.FindFirst (strItemCriteria)
If .NoMatch Then
MsgBox "No Match Found"
End If
End With
Set rs = Nothing
End Sub
Go to the top of the page
 
theDBguy
post Jan 17 2020, 04:25 PM
Post#25


UA Moderator
Posts: 77,481
Joined: 19-June 07
From: SunnySandyEggo


Hi. Other options to share your db are to email me a copy and/or we can do a web meeting with screen sharing.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
2 Pages V < 1 2


Custom Search


RSSSearch   Top   Lo-Fi    17th February 2020 - 05:06 AM