Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RecordsetClone No Current Record

Status
Not open for further replies.

mmogul

IS-IT--Management
Dec 1, 2003
218
0
0
US
I have a form that uses an unbound combobox to select the record displayed. The user box selects a ProjectID and the form shows information about the project. This form has a recordsource that uses a query based on a single table. My code here is working fine.

When I attempt to open the form and pass the project ID to this form, the search in the recordset clone does not find the record. It does populate the combo box. But, if the called form was already open, then the recordset clone does find the record.

I have been unable to figure this one out. Please help



Here is the code:
Code:
Public Function OpenMaintainShows(iRecordID As Long) As Boolean
'** I am passing in the Record ID that I want to display on the target form (frmShows_Maintain2)

Dim rs As Object
Dim frm As Form

If IsObjectOpen("frmShows_Maintain2", acForm) Then  '** This calls a function to see if the form is already open
    Forms("frmShows_Maintain2").SetFocus
    Forms("frmShows_Maintain2").cmbShows = iRecordID
        
Else

    DoCmd.OpenForm FormName:="frmShows_Maintain2", View:=acNormal
                   
    Forms("frmShows_Maintain2").cmbShows = iRecordID

End If

'***************************************************************************************************
'** If the target form is open, then this code will work
'** If the target form is closed, the code opens the form, the value in the combo box is updated, but
'** the record is not retrieved
'***************************************************************************************************
Set frm = Forms("frmShows_Maintain2")

Set rs = frm.RecordsetClone
Debug.Print frm.cmbShows.Value
rs.FindFirst "ShowID = " & CInt(frm.cmbShows.Value)
If rs.NoMatch Then
    Debug.Print "did not find record"
Else
    
    frm.Bookmark = rs.Bookmark
End If
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top