J
johnlute
I've tried posting this a couple other times but have yet to resolve
it. My apologies for multiple posts and any confusion this may have
caused. I'm really having trouble with this and have not been very
clear. Hopefully, I'm more crystal than mud now and someone can see
the error.
I have a form [frmPackaging] which has a combobox [cbqrytypes] that's
part of the form's record source:
SELECT tblProfiles.*, tblProfiles.Type AS PKType
FROM tblProfiles
WHERE (((tblProfiles.Type)=[Forms]![frmPackaging]![cbqrytypes])) OR
((([Forms]![frmPackaging].[Form]![cbqrytypes]) Is Null));
[cbqryTypes] has an AfterUpdate event that changes the form's record
source:
Private Sub cbqrytypes_AfterUpdate()
Me.FilterOn = False
Me.Filter = ""
Forms![frmPackaging].Form.Requery
Me.cbProfileID.Requery
Me.cbProfileID.SetFocus
End Sub
This works fine EXCEPT when [frmPackaging] is opened from another form
via this double click:
Private Sub cbProfilesAssociations_DblClick(Cancel As Integer)
Dim strFormToOpen As String
Dim strProfileType As String
With Me!cbProfilesAssociations
'If no selection has been made, we can't do anything useful.
If IsNull(.Value) Then
Exit Sub
End If
'Here a selection has been made, so open the appropriate form
'for the selection.
'Lookup the form, returning a null string if none is
specified.
strProfileType = .Column(3)
strFormToOpen = vbNullString & _
DLookup("FormToOpen", "tblProfileTypes", _
"txtProfileType=""" & .Column(3) & """")
'If we have a form to open, do that.
If Len(strFormToOpen) > 0 Then
DoCmd.OpenForm strFormToOpen, acNormal, _
WhereCondition:="txtProfileID=""" & .Value & """"
'If this is the packaging form, set it up to show the
'desired profile type.
If strFormToOpen = "frmPackaging" Then
With Forms!frmPackaging
!cbqrytypes = strProfileType
End With
End If
End If
End With
End Sub
When using the above double click event [frmPackaging] opens and is
filtered to the desired record. In this state I want to requery
[frmPackaging] so I change the value in [cbqrytypes] and what happens
is:
1. The [frmPackaging] filter is turned off and the form requeries.
2. [cbqrytypes] displays the selected value however [frmPackaging]
requeries to the entire record set - it doesn't requery to the value
selected in [cbqrytypes].
Can anyone see why this is?
Thanks for your time and support!
it. My apologies for multiple posts and any confusion this may have
caused. I'm really having trouble with this and have not been very
clear. Hopefully, I'm more crystal than mud now and someone can see
the error.
I have a form [frmPackaging] which has a combobox [cbqrytypes] that's
part of the form's record source:
SELECT tblProfiles.*, tblProfiles.Type AS PKType
FROM tblProfiles
WHERE (((tblProfiles.Type)=[Forms]![frmPackaging]![cbqrytypes])) OR
((([Forms]![frmPackaging].[Form]![cbqrytypes]) Is Null));
[cbqryTypes] has an AfterUpdate event that changes the form's record
source:
Private Sub cbqrytypes_AfterUpdate()
Me.FilterOn = False
Me.Filter = ""
Forms![frmPackaging].Form.Requery
Me.cbProfileID.Requery
Me.cbProfileID.SetFocus
End Sub
This works fine EXCEPT when [frmPackaging] is opened from another form
via this double click:
Private Sub cbProfilesAssociations_DblClick(Cancel As Integer)
Dim strFormToOpen As String
Dim strProfileType As String
With Me!cbProfilesAssociations
'If no selection has been made, we can't do anything useful.
If IsNull(.Value) Then
Exit Sub
End If
'Here a selection has been made, so open the appropriate form
'for the selection.
'Lookup the form, returning a null string if none is
specified.
strProfileType = .Column(3)
strFormToOpen = vbNullString & _
DLookup("FormToOpen", "tblProfileTypes", _
"txtProfileType=""" & .Column(3) & """")
'If we have a form to open, do that.
If Len(strFormToOpen) > 0 Then
DoCmd.OpenForm strFormToOpen, acNormal, _
WhereCondition:="txtProfileID=""" & .Value & """"
'If this is the packaging form, set it up to show the
'desired profile type.
If strFormToOpen = "frmPackaging" Then
With Forms!frmPackaging
!cbqrytypes = strProfileType
End With
End If
End If
End With
End Sub
When using the above double click event [frmPackaging] opens and is
filtered to the desired record. In this state I want to requery
[frmPackaging] so I change the value in [cbqrytypes] and what happens
is:
1. The [frmPackaging] filter is turned off and the form requeries.
2. [cbqrytypes] displays the selected value however [frmPackaging]
requeries to the entire record set - it doesn't requery to the value
selected in [cbqrytypes].
Can anyone see why this is?
Thanks for your time and support!