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
> List Box, Main Form And Subform, Access 2016    
 
   
LilAnnCC1
post Jun 25 2019, 09:35 AM
Post#1



Posts: 805
Joined: 31-May 04
From: Wisconsin, USA


Hello all!

I have a Main form called f_Sale. On this form, I have a subform called sf_SaleDetail (not a continous form) in a tab control. I also have a listbox on the f_Sale form called lstItems (listing all the items on the sf_SaleDetail).

Previously I had the list box in the sf_SaleDetail form and I was able to click on the list box and it the record on the sf_SaleDetail would be highlighted using this code:

CODE
'Go to the item detail
    Dim x As Long
    x = Me.ID 'OrderDetailID
    
   Me.Parent.Recordset.FindFirst "ID=" & Nz(x, 0)
   Me.Parent![Line].SetFocus


As I have moved the list box out of the subform and onto the Main form, this code obviously doesn't work anymore.

I've managed to get this far with no error messages, but it doesn't do anything:

CODE
     Forms!f_Sale!sf_SaleDetail.Form.Recordset.FindFirst "ID=" & x


I've been working on this for a couple of hours and am now looking for some help.

How to I go to the record I want from the list box?

--------------------
I am eternally grateful to all the people here who continually help get me out of jams!

Access 2010
Go to the top of the page
 
theDBguy
post Jun 25 2019, 09:56 AM
Post#2


Access Wiki and Forums Moderator
Posts: 75,722
Joined: 19-June 07
From: SunnySandyEggo


Hi. When the Recordset fails me, I usually try to use the RecordsetClone instead.

--------------------
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
 
LilAnnCC1
post Jun 25 2019, 10:05 AM
Post#3



Posts: 805
Joined: 31-May 04
From: Wisconsin, USA


I changed it to:

Forms!f_Sale!sf_SaleDetail.Form.RecordsetClone.FindFirst "ID=" & Nz(x, 0)
Forms!f_Sale!sf_SaleDetail.Form.[Line].SetFocus

and still nothing.

Again, no error messages at all. When I put in a breakpoint, it goes through the entire code and acts like it is working, but nothing changes on the actual sf_SaleDetail form. It won't even set the focus on the form.

--------------------
I am eternally grateful to all the people here who continually help get me out of jams!

Access 2010
Go to the top of the page
 
theDBguy
post Jun 25 2019, 10:23 AM
Post#4


Access Wiki and Forums Moderator
Posts: 75,722
Joined: 19-June 07
From: SunnySandyEggo


Hi. I guess I forgot to mention, when I said RecordsetClone, I was referring to using a RecordsetClone, do a FindFirst on it, and then set the Bookmark of the form to the clone's bookmark.

--------------------
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
 
LilAnnCC1
post Jun 25 2019, 11:14 AM
Post#5



Posts: 805
Joined: 31-May 04
From: Wisconsin, USA


I appreciate you pretending to know that I know what I'm doing! You're so sweet!

This is what I have so far:

CODE
Private Sub lstItems_Click()
On Error GoTo ErrorHandling_Error

'Go to the item detail
    Dim x As Long
    x = Me.ID 'OrderDetailID
    Dim rs As DAO.Recordset
    
     Set rs = Forms!f_Sale!sf_SaleDetail.Form.Recordset.Clone
     rs.FindFirst "ID=" & Nz(x, 0)
     If Not rs.EOF Then
        Forms!f_Sale!sf_SaleDetail.Bookmark = rs.Bookmark      [color="#FF0000"]---------It errors here. Error 438--Object doesn't support this property or method.[/color]
     End If
    
ErrorHandling_Exit:
Set rs = Nothing
Exit Sub

ErrorHandling_Error:
'      If Err.Number = Then
'      Else
             MsgBox "Unexpected error - " & Err.Number & vbCrLf & vbCrLf & Error$, vbExclamation, "lstItems_Click"
'      End If
Resume ErrorHandling_Exit
End Sub


So, what am I doing wrong?

--------------------
I am eternally grateful to all the people here who continually help get me out of jams!

Access 2010
Go to the top of the page
 
LilAnnCC1
post Jun 25 2019, 11:20 AM
Post#6



Posts: 805
Joined: 31-May 04
From: Wisconsin, USA


OMG! OMG! OMG! I got it!

I was pulling the Sales ID instead of the SalesDetailID and I added form to Forms!f_Sale!sf_SaleDetail.Form.Bookmark = rs.Bookmark

It works!

Thank you so much for sticking with me!

--------------------
I am eternally grateful to all the people here who continually help get me out of jams!

Access 2010
Go to the top of the page
 
theDBguy
post Jun 25 2019, 11:23 AM
Post#7


Access Wiki and Forums Moderator
Posts: 75,722
Joined: 19-June 07
From: SunnySandyEggo


See! I knew you knew what you were doing!! Cheers!!! cheers.gif

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


Custom Search


RSSSearch   Top   Lo-Fi    19th July 2019 - 05:09 AM