On Open revisited

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I posted this previously and Dirk Glodgar and Albert Kallal provided some
solutions however I'm finding that the solution needs more.

Here is my original post:

I'd like to open a form and filter based on another form's combo box.

The form and cbox is:
frmFinishedGoods.cbProfileID

The form I'd like to open based on the above form's cbox is:
frmQueryFGProcessingFacIDsLineIDs.cbNavigateProfiles

cbProfileID and cbNavigateProfiles source the same table and field. I'd like
cbNavigateProfiles to filter to the record in cbProfileID.

How can I code the On Open property of my form to achieve this?

The solution to this was to code the Event Procedure of a button to this:

Private Sub cmdGOrpt_Click()
On Error GoTo Err_cmdGOrpt_Click

Dim stDocName As String

DoCmd.OpenForm "frmQueryFGProcessingFacIDsLineIDs"

Forms!frmQueryFGProcessingFacIDsLineIDs!cbNavigateProfiles = _
Forms!frmFinishedGoods!cbProfileID

DoCmd.OpenForm Me!cbSelectReportRQ, acNormal

Exit_cmdGOrpt_Click:
Exit Sub

Err_cmdGOrpt_Click:
MsgBox Err.Description
Resume Exit_cmdGOrpt_Click

End Sub

This works fine however the button is now going to be used to open up any
forms that are selected in cbSelectReportRQ.

So now I'm back to square one which is:

cbProfileID and cbNavigateProfiles source the same table and field. I'd like
cbNavigateProfiles to filter to the record in cbProfileID.

How can I code the On Open property of frmQueryFGProcessingFacIDsLineIDs to
achieve this?
 
Assuming [ProfileID] is a field in the record source for
frmQueryFGProcessingFacIDsLineIDs that you want to filter on, use the Where
argument of the OpenForm method.

strWhere = "[ProfileID] = '" & Me.cbProfileID & "'"
Docmd.OpenForm "frmQueryFGProcessingFacIDsLineIDs", , , strWhere
 
Thanks, Klatuut!

I gave it a try:

Private Sub Form_Open(Cancel As Integer)
strWhere = "[txtProfileID] = '" & Me.cbNavigateProfiles & "'"
DoCmd.OpenForm "frmQueryFGProcessingFacIDsLineIDs", , , strWhere
End Sub

It's not working. The form opens fine just not to the expected record. The
debugger doesn't fire up, either so I'm not sure as to why. Do you see
anything?
 
Back
Top