|
|
I have a unbound combo box used to find a record on a My form F_Parts it uses the rs.FindFirst "[PartNumberID] code that the Wizard Supplies on the after Update,
I also have code on my forms "On Current" that keeps the combo displaying the correct info if navigation buttons are used Me.SelectByPNID_Combo = Me.PartNumberID
the issue i am now having is Code from my F_search that opens this form uses a Where statement to open this form so my F_Parts is opened "Filtered" and the find record combos no longer work and display wierd data that is misleading.
Here is the code from my search Form
Private Sub OpenParts_Click(Cancel As Integer) On Error GoTo Err_OpenParts_Click
Dim stDocName As String Dim stLinkCriteria As String
stDocName = "F_Parts" stLinkCriteria = "[PartNumberID]=" & Me![ID] DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_OpenParts_Click: Exit Sub
Err_OpenParts_Click: MsgBox Err.Description Resume Exit_OpenParts_Click: End Sub
Is there a way to remove the filter so my Parts form can still use the lookup Combos if a user wants to explore other records maybe on Form Activate?
I have tried a few things but my form resets to the first record when i remove filters with VBA
Any help would be appreciated..
|
|
Hi Barry A&P, one way I sometimes use is: Instead of opening the search form with a where clause, pass the PartNumberID in the OpenArgs. In the load event retrieve the value of the ID. Assuming the ID is a number and not a string:
If Len(Me.OpenArgs & vbNullString) >0 Then Me.NameOfCombo = Nz( Me.OpenArgs,0) Call NameOfCombo_AfterUpdate End If
Replace the obvious with your control names.
Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
"Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message news:A2114F8D-A5B8-4732-ABC0-0A6E32C499DC[ at ]microsoft.com...
[Quoted Text] >I have a unbound combo box used to find a record on a My form F_Parts > it uses the rs.FindFirst "[PartNumberID] code that the Wizard Supplies on > the after Update, > > I also have code on my forms "On Current" that keeps the combo displaying > the correct info if navigation buttons are used Me.SelectByPNID_Combo = > Me.PartNumberID > > the issue i am now having is Code from my F_search that opens this form > uses > a Where statement to open this form so my F_Parts is opened "Filtered" and > the find record combos no longer work and display wierd data that is > misleading. > > Here is the code from my search Form > > Private Sub OpenParts_Click(Cancel As Integer) > On Error GoTo Err_OpenParts_Click > > Dim stDocName As String > Dim stLinkCriteria As String > > stDocName = "F_Parts" > > stLinkCriteria = "[PartNumberID]=" & Me![ID] > DoCmd.OpenForm stDocName, , , stLinkCriteria > > Exit_OpenParts_Click: > Exit Sub > > Err_OpenParts_Click: > MsgBox Err.Description > Resume Exit_OpenParts_Click: > End Sub > > Is there a way to remove the filter so my Parts form can still use the > lookup Combos if a user wants to explore other records > maybe on Form Activate? > > I have tried a few things but my form resets to the first record when i > remove filters with VBA > > Any help would be appreciated..
|
|
Jeanette Thank you so much for the great Fix.......
"Jeanette Cunningham" wrote:
[Quoted Text] > Hi Barry A&P, > one way I sometimes use is: > Instead of opening the search form with a where clause, pass the > PartNumberID in the OpenArgs. > In the load event retrieve the value of the ID. > Assuming the ID is a number and not a string: > > If Len(Me.OpenArgs & vbNullString) >0 Then > Me.NameOfCombo = Nz( Me.OpenArgs,0) > Call NameOfCombo_AfterUpdate > End If > > Replace the obvious with your control names. > > > Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia > > > "Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message > news:A2114F8D-A5B8-4732-ABC0-0A6E32C499DC[ at ]microsoft.com... > >I have a unbound combo box used to find a record on a My form F_Parts > > it uses the rs.FindFirst "[PartNumberID] code that the Wizard Supplies on > > the after Update, > > > > I also have code on my forms "On Current" that keeps the combo displaying > > the correct info if navigation buttons are used Me.SelectByPNID_Combo = > > Me.PartNumberID > > > > the issue i am now having is Code from my F_search that opens this form > > uses > > a Where statement to open this form so my F_Parts is opened "Filtered" and > > the find record combos no longer work and display wierd data that is > > misleading. > > > > Here is the code from my search Form > > > > Private Sub OpenParts_Click(Cancel As Integer) > > On Error GoTo Err_OpenParts_Click > > > > Dim stDocName As String > > Dim stLinkCriteria As String > > > > stDocName = "F_Parts" > > > > stLinkCriteria = "[PartNumberID]=" & Me![ID] > > DoCmd.OpenForm stDocName, , , stLinkCriteria > > > > Exit_OpenParts_Click: > > Exit Sub > > > > Err_OpenParts_Click: > > MsgBox Err.Description > > Resume Exit_OpenParts_Click: > > End Sub > > > > Is there a way to remove the filter so my Parts form can still use the > > lookup Combos if a user wants to explore other records > > maybe on Form Activate? > > > > I have tried a few things but my form resets to the first record when i > > remove filters with VBA > > > > Any help would be appreciated.. > > >
|
|
Jeanette I have discovered this code doesnt work if the form is allready opened, Can you help me with the code on this?? maybe on load or on activate??
Thanks
"Barry A&P" wrote:
[Quoted Text] > Jeanette Thank you so much for the great Fix....... > > "Jeanette Cunningham" wrote: > > > Hi Barry A&P, > > one way I sometimes use is: > > Instead of opening the search form with a where clause, pass the > > PartNumberID in the OpenArgs. > > In the load event retrieve the value of the ID. > > Assuming the ID is a number and not a string: > > > > If Len(Me.OpenArgs & vbNullString) >0 Then > > Me.NameOfCombo = Nz( Me.OpenArgs,0) > > Call NameOfCombo_AfterUpdate > > End If > > > > Replace the obvious with your control names. > > > > > > Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia > > > > > > "Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message > > news:A2114F8D-A5B8-4732-ABC0-0A6E32C499DC[ at ]microsoft.com... > > >I have a unbound combo box used to find a record on a My form F_Parts > > > it uses the rs.FindFirst "[PartNumberID] code that the Wizard Supplies on > > > the after Update, > > > > > > I also have code on my forms "On Current" that keeps the combo displaying > > > the correct info if navigation buttons are used Me.SelectByPNID_Combo = > > > Me.PartNumberID > > > > > > the issue i am now having is Code from my F_search that opens this form > > > uses > > > a Where statement to open this form so my F_Parts is opened "Filtered" and > > > the find record combos no longer work and display wierd data that is > > > misleading. > > > > > > Here is the code from my search Form > > > > > > Private Sub OpenParts_Click(Cancel As Integer) > > > On Error GoTo Err_OpenParts_Click > > > > > > Dim stDocName As String > > > Dim stLinkCriteria As String > > > > > > stDocName = "F_Parts" > > > > > > stLinkCriteria = "[PartNumberID]=" & Me![ID] > > > DoCmd.OpenForm stDocName, , , stLinkCriteria > > > > > > Exit_OpenParts_Click: > > > Exit Sub > > > > > > Err_OpenParts_Click: > > > MsgBox Err.Description > > > Resume Exit_OpenParts_Click: > > > End Sub > > > > > > Is there a way to remove the filter so my Parts form can still use the > > > lookup Combos if a user wants to explore other records > > > maybe on Form Activate? > > > > > > I have tried a few things but my form resets to the first record when i > > > remove filters with VBA > > > > > > Any help would be appreciated.. > > > > > >
|
|
If the form is already open, you can set the value of the combo directly from the other form. Run code something like this on the form with the combo, not sure which event would be best for this:
Me.NameOfCombo = Forms!frmOtherForm.NameOfControlWithPKID Call NameOfCombo_AfterUpdate
Replace the obvious with your control and form names.
Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
"Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message news:24CC48F6-41BC-42E4-AE31-C34A56C157AF[ at ]microsoft.com...
[Quoted Text] > Jeanette > I have discovered this code doesnt work if the form is allready opened, > Can > you help me with the code on this?? maybe on load or on activate?? > > Thanks > > "Barry A&P" wrote: > >> Jeanette Thank you so much for the great Fix....... >> >> "Jeanette Cunningham" wrote: >> >> > Hi Barry A&P, >> > one way I sometimes use is: >> > Instead of opening the search form with a where clause, pass the >> > PartNumberID in the OpenArgs. >> > In the load event retrieve the value of the ID. >> > Assuming the ID is a number and not a string: >> > >> > If Len(Me.OpenArgs & vbNullString) >0 Then >> > Me.NameOfCombo = Nz( Me.OpenArgs,0) >> > Call NameOfCombo_AfterUpdate >> > End If >> > >> > Replace the obvious with your control names. >> > >> > >> > Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia >> > >> > >> > "Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message >> > news:A2114F8D-A5B8-4732-ABC0-0A6E32C499DC[ at ]microsoft.com... >> > >I have a unbound combo box used to find a record on a My form F_Parts >> > > it uses the rs.FindFirst "[PartNumberID] code that the Wizard >> > > Supplies on >> > > the after Update, >> > > >> > > I also have code on my forms "On Current" that keeps the combo >> > > displaying >> > > the correct info if navigation buttons are used Me.SelectByPNID_Combo >> > > = >> > > Me.PartNumberID >> > > >> > > the issue i am now having is Code from my F_search that opens this >> > > form >> > > uses >> > > a Where statement to open this form so my F_Parts is opened >> > > "Filtered" and >> > > the find record combos no longer work and display wierd data that is >> > > misleading. >> > > >> > > Here is the code from my search Form >> > > >> > > Private Sub OpenParts_Click(Cancel As Integer) >> > > On Error GoTo Err_OpenParts_Click >> > > >> > > Dim stDocName As String >> > > Dim stLinkCriteria As String >> > > >> > > stDocName = "F_Parts" >> > > >> > > stLinkCriteria = "[PartNumberID]=" & Me![ID] >> > > DoCmd.OpenForm stDocName, , , stLinkCriteria >> > > >> > > Exit_OpenParts_Click: >> > > Exit Sub >> > > >> > > Err_OpenParts_Click: >> > > MsgBox Err.Description >> > > Resume Exit_OpenParts_Click: >> > > End Sub >> > > >> > > Is there a way to remove the filter so my Parts form can still use >> > > the >> > > lookup Combos if a user wants to explore other records >> > > maybe on Form Activate? >> > > >> > > I have tried a few things but my form resets to the first record when >> > > i >> > > remove filters with VBA >> > > >> > > Any help would be appreciated.. >> > >> > >> >
|
|
Jeanette im sorry but i just cant quite get it to work A little more info. datasheet form that displays a filtered set of records named F_BrowseParts if the PartNumber_textbox is double clicked i used your code to open F_InventoryTransactions and set a record with Openargs=Me![id]
Private Sub PartNumber_Textbox_DblClick(Cancel As Integer) On Error GoTo Err_PartNumber_Textbox_DblClick
Dim stDocName As String stDocName = "F_InventoryTransactions" DoCmd.OpenForm stDocName, , , , , , Me![ID]
Exit_PartNumber_Textbox_DblClick: Exit Sub
Err_PartNumber_Textbox_DblClick: MsgBox Err.Description Resume Exit_PartNumber_Textbox_DblClick: End Sub
Then I set up the F_Inventorytransactions to accept the openargs with
Private Sub Form_Load() If Len(Me.OpenArgs & vbNullString) > 0 Then Me.SelectByPNID_Combo = Nz(Me.OpenArgs, 0) Call SelectByPNID_Combo_AfterUpdate End If
End Sub
However if the F_Inventorytransactions is allready open nothing happens i would like to be able to open the F_inventorytransactions from a switchboard, and from the Browse records form, maybe a If Not IsLoaded("F_InventoryTransactions") Then is needed somewhere in my PartNumber_Textbox_DblClick Code but i cant figure how to get it in there.
Any help would be appreciated Barry
"Jeanette Cunningham" wrote:
[Quoted Text] > If the form is already open, you can set the value of the combo directly > from the other form. > Run code something like this on the form with the combo, not sure which > event would be best for this: > > > Me.NameOfCombo = Forms!frmOtherForm.NameOfControlWithPKID > Call NameOfCombo_AfterUpdate > > > Replace the obvious with your control and form names. > > Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia > > > "Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message > news:24CC48F6-41BC-42E4-AE31-C34A56C157AF[ at ]microsoft.com... > > Jeanette > > I have discovered this code doesnt work if the form is allready opened, > > Can > > you help me with the code on this?? maybe on load or on activate?? > > > > Thanks > > > > "Barry A&P" wrote: > > > >> Jeanette Thank you so much for the great Fix....... > >> > >> "Jeanette Cunningham" wrote: > >> > >> > Hi Barry A&P, > >> > one way I sometimes use is: > >> > Instead of opening the search form with a where clause, pass the > >> > PartNumberID in the OpenArgs. > >> > In the load event retrieve the value of the ID. > >> > Assuming the ID is a number and not a string: > >> > > >> > If Len(Me.OpenArgs & vbNullString) >0 Then > >> > Me.NameOfCombo = Nz( Me.OpenArgs,0) > >> > Call NameOfCombo_AfterUpdate > >> > End If > >> > > >> > Replace the obvious with your control names. > >> > > >> > > >> > Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia > >> > > >> > > >> > "Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message > >> > news:A2114F8D-A5B8-4732-ABC0-0A6E32C499DC[ at ]microsoft.com... > >> > >I have a unbound combo box used to find a record on a My form F_Parts > >> > > it uses the rs.FindFirst "[PartNumberID] code that the Wizard > >> > > Supplies on > >> > > the after Update, > >> > > > >> > > I also have code on my forms "On Current" that keeps the combo > >> > > displaying > >> > > the correct info if navigation buttons are used Me.SelectByPNID_Combo > >> > > = > >> > > Me.PartNumberID > >> > > > >> > > the issue i am now having is Code from my F_search that opens this > >> > > form > >> > > uses > >> > > a Where statement to open this form so my F_Parts is opened > >> > > "Filtered" and > >> > > the find record combos no longer work and display wierd data that is > >> > > misleading. > >> > > > >> > > Here is the code from my search Form > >> > > > >> > > Private Sub OpenParts_Click(Cancel As Integer) > >> > > On Error GoTo Err_OpenParts_Click > >> > > > >> > > Dim stDocName As String > >> > > Dim stLinkCriteria As String > >> > > > >> > > stDocName = "F_Parts" > >> > > > >> > > stLinkCriteria = "[PartNumberID]=" & Me![ID] > >> > > DoCmd.OpenForm stDocName, , , stLinkCriteria > >> > > > >> > > Exit_OpenParts_Click: > >> > > Exit Sub > >> > > > >> > > Err_OpenParts_Click: > >> > > MsgBox Err.Description > >> > > Resume Exit_OpenParts_Click: > >> > > End Sub > >> > > > >> > > Is there a way to remove the filter so my Parts form can still use > >> > > the > >> > > lookup Combos if a user wants to explore other records > >> > > maybe on Form Activate? > >> > > > >> > > I have tried a few things but my form resets to the first record when > >> > > i > >> > > remove filters with VBA > >> > > > >> > > Any help would be appreciated.. > >> > > >> > > >> > > > >
|
|
"Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message news:402166B4-EE0B-411D-8F3B-1A2063EB80ED[ at ]microsoft.com...
[Quoted Text] > Jeanette im sorry but i just cant quite get it to work > A little more info. > datasheet form that displays a filtered set of records named F_BrowseParts > if the PartNumber_textbox is double clicked i used your code to open > F_InventoryTransactions and set a record with Openargs=Me![id] > > Private Sub PartNumber_Textbox_DblClick(Cancel As Integer) > On Error GoTo Err_PartNumber_Textbox_DblClick > > Dim stDocName As String > stDocName = "F_InventoryTransactions" > DoCmd.OpenForm stDocName, , , , , , Me![ID] > > Exit_PartNumber_Textbox_DblClick: > Exit Sub > > Err_PartNumber_Textbox_DblClick: > MsgBox Err.Description > Resume Exit_PartNumber_Textbox_DblClick: > End Sub > > Then I set up the F_Inventorytransactions to accept the openargs with > > Private Sub Form_Load() > If Len(Me.OpenArgs & vbNullString) > 0 Then > Me.SelectByPNID_Combo = Nz(Me.OpenArgs, 0) > Call SelectByPNID_Combo_AfterUpdate > End If > > End Sub > > However if the F_Inventorytransactions is allready open nothing happens > i would like to be able to open the F_inventorytransactions from a > switchboard, and from the Browse records form, maybe a > If Not IsLoaded("F_InventoryTransactions") Then is needed somewhere in my > PartNumber_Textbox_DblClick Code but i cant figure how to get it in there. > > Any help would be appreciated > Barry > > "Jeanette Cunningham" wrote: > >> If the form is already open, you can set the value of the combo directly >> from the other form. >> Run code something like this on the form with the combo, not sure which >> event would be best for this: >> >> >> Me.NameOfCombo = Forms!frmOtherForm.NameOfControlWithPKID >> Call NameOfCombo_AfterUpdate >> >> >> Replace the obvious with your control and form names. >> >> Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia >> >> >> "Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message >> news:24CC48F6-41BC-42E4-AE31-C34A56C157AF[ at ]microsoft.com... >> > Jeanette >> > I have discovered this code doesnt work if the form is allready opened, >> > Can >> > you help me with the code on this?? maybe on load or on activate?? >> > >> > Thanks >> > >> > "Barry A&P" wrote: >> > >> >> Jeanette Thank you so much for the great Fix....... >> >> >> >> "Jeanette Cunningham" wrote: >> >> >> >> > Hi Barry A&P, >> >> > one way I sometimes use is: >> >> > Instead of opening the search form with a where clause, pass the >> >> > PartNumberID in the OpenArgs. >> >> > In the load event retrieve the value of the ID. >> >> > Assuming the ID is a number and not a string: >> >> > >> >> > If Len(Me.OpenArgs & vbNullString) >0 Then >> >> > Me.NameOfCombo = Nz( Me.OpenArgs,0) >> >> > Call NameOfCombo_AfterUpdate >> >> > End If >> >> > >> >> > Replace the obvious with your control names. >> >> > >> >> > >> >> > Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia >> >> > >> >> > >> >> > "Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message >> >> > news:A2114F8D-A5B8-4732-ABC0-0A6E32C499DC[ at ]microsoft.com... >> >> > >I have a unbound combo box used to find a record on a My form >> >> > >F_Parts >> >> > > it uses the rs.FindFirst "[PartNumberID] code that the Wizard >> >> > > Supplies on >> >> > > the after Update, >> >> > > >> >> > > I also have code on my forms "On Current" that keeps the combo >> >> > > displaying >> >> > > the correct info if navigation buttons are used >> >> > > Me.SelectByPNID_Combo >> >> > > = >> >> > > Me.PartNumberID >> >> > > >> >> > > the issue i am now having is Code from my F_search that opens this >> >> > > form >> >> > > uses >> >> > > a Where statement to open this form so my F_Parts is opened >> >> > > "Filtered" and >> >> > > the find record combos no longer work and display wierd data that >> >> > > is >> >> > > misleading. >> >> > > >> >> > > Here is the code from my search Form >> >> > > >> >> > > Private Sub OpenParts_Click(Cancel As Integer) >> >> > > On Error GoTo Err_OpenParts_Click >> >> > > >> >> > > Dim stDocName As String >> >> > > Dim stLinkCriteria As String >> >> > > >> >> > > stDocName = "F_Parts" >> >> > > >> >> > > stLinkCriteria = "[PartNumberID]=" & Me![ID] >> >> > > DoCmd.OpenForm stDocName, , , stLinkCriteria >> >> > > >> >> > > Exit_OpenParts_Click: >> >> > > Exit Sub >> >> > > >> >> > > Err_OpenParts_Click: >> >> > > MsgBox Err.Description >> >> > > Resume Exit_OpenParts_Click: >> >> > > End Sub >> >> > > >> >> > > Is there a way to remove the filter so my Parts form can still use >> >> > > the >> >> > > lookup Combos if a user wants to explore other records >> >> > > maybe on Form Activate? >> >> > > >> >> > > I have tried a few things but my form resets to the first record >> >> > > when >> >> > > i >> >> > > remove filters with VBA >> >> > > >> >> > > Any help would be appreciated.. >> >> > >> >> > >> >> > >> >> >>
|
|
The easiest option would to be to close F_InventoryTransactions (if it is open) before you open it.
Private Sub PartNumber_Textbox_DblClick(Cancel As Integer) On Error GoTo Err_PartNumber_Textbox_DblClick Dim stDocName As String stDocName = "F_InventoryTransactions"
If CurrentProject.AllForms(stDocName).IsLoaded Then DoCmd.Close acForm, stDocName End If
DoCmd.OpenForm stDocName, , , , , , Me![ID]
Exit_PartNumber_Textbox_DblClick: Exit Sub
Err_PartNumber_Textbox_DblClick: MsgBox Err.Description Resume Exit_PartNumber_Textbox_DblClick: End Sub
"Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message news:402166B4-EE0B-411D-8F3B-1A2063EB80ED[ at ]microsoft.com...
[Quoted Text] > Jeanette im sorry but i just cant quite get it to work > A little more info. > datasheet form that displays a filtered set of records named F_BrowseParts > if the PartNumber_textbox is double clicked i used your code to open > F_InventoryTransactions and set a record with Openargs=Me![id] > > Private Sub PartNumber_Textbox_DblClick(Cancel As Integer) > On Error GoTo Err_PartNumber_Textbox_DblClick > > Dim stDocName As String > stDocName = "F_InventoryTransactions" > DoCmd.OpenForm stDocName, , , , , , Me![ID] > > Exit_PartNumber_Textbox_DblClick: > Exit Sub > > Err_PartNumber_Textbox_DblClick: > MsgBox Err.Description > Resume Exit_PartNumber_Textbox_DblClick: > End Sub > > Then I set up the F_Inventorytransactions to accept the openargs with > > Private Sub Form_Load() > If Len(Me.OpenArgs & vbNullString) > 0 Then > Me.SelectByPNID_Combo = Nz(Me.OpenArgs, 0) > Call SelectByPNID_Combo_AfterUpdate > End If > > End Sub > > However if the F_Inventorytransactions is allready open nothing happens > i would like to be able to open the F_inventorytransactions from a > switchboard, and from the Browse records form, maybe a > If Not IsLoaded("F_InventoryTransactions") Then is needed somewhere in my > PartNumber_Textbox_DblClick Code but i cant figure how to get it in there. > > Any help would be appreciated > Barry > > "Jeanette Cunningham" wrote: > >> If the form is already open, you can set the value of the combo directly >> from the other form. >> Run code something like this on the form with the combo, not sure which >> event would be best for this: >> >> >> Me.NameOfCombo = Forms!frmOtherForm.NameOfControlWithPKID >> Call NameOfCombo_AfterUpdate >> >> >> Replace the obvious with your control and form names. >> >> Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia >> >> >> "Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message >> news:24CC48F6-41BC-42E4-AE31-C34A56C157AF[ at ]microsoft.com... >> > Jeanette >> > I have discovered this code doesnt work if the form is allready opened, >> > Can >> > you help me with the code on this?? maybe on load or on activate?? >> > >> > Thanks >> > >> > "Barry A&P" wrote: >> > >> >> Jeanette Thank you so much for the great Fix....... >> >> >> >> "Jeanette Cunningham" wrote: >> >> >> >> > Hi Barry A&P, >> >> > one way I sometimes use is: >> >> > Instead of opening the search form with a where clause, pass the >> >> > PartNumberID in the OpenArgs. >> >> > In the load event retrieve the value of the ID. >> >> > Assuming the ID is a number and not a string: >> >> > >> >> > If Len(Me.OpenArgs & vbNullString) >0 Then >> >> > Me.NameOfCombo = Nz( Me.OpenArgs,0) >> >> > Call NameOfCombo_AfterUpdate >> >> > End If >> >> > >> >> > Replace the obvious with your control names. >> >> > >> >> > >> >> > Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia >> >> > >> >> > >> >> > "Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message >> >> > news:A2114F8D-A5B8-4732-ABC0-0A6E32C499DC[ at ]microsoft.com... >> >> > >I have a unbound combo box used to find a record on a My form >> >> > >F_Parts >> >> > > it uses the rs.FindFirst "[PartNumberID] code that the Wizard >> >> > > Supplies on >> >> > > the after Update, >> >> > > >> >> > > I also have code on my forms "On Current" that keeps the combo >> >> > > displaying >> >> > > the correct info if navigation buttons are used >> >> > > Me.SelectByPNID_Combo >> >> > > = >> >> > > Me.PartNumberID >> >> > > >> >> > > the issue i am now having is Code from my F_search that opens this >> >> > > form >> >> > > uses >> >> > > a Where statement to open this form so my F_Parts is opened >> >> > > "Filtered" and >> >> > > the find record combos no longer work and display wierd data that >> >> > > is >> >> > > misleading. >> >> > > >> >> > > Here is the code from my search Form >> >> > > >> >> > > Private Sub OpenParts_Click(Cancel As Integer) >> >> > > On Error GoTo Err_OpenParts_Click >> >> > > >> >> > > Dim stDocName As String >> >> > > Dim stLinkCriteria As String >> >> > > >> >> > > stDocName = "F_Parts" >> >> > > >> >> > > stLinkCriteria = "[PartNumberID]=" & Me![ID] >> >> > > DoCmd.OpenForm stDocName, , , stLinkCriteria >> >> > > >> >> > > Exit_OpenParts_Click: >> >> > > Exit Sub >> >> > > >> >> > > Err_OpenParts_Click: >> >> > > MsgBox Err.Description >> >> > > Resume Exit_OpenParts_Click: >> >> > > End Sub >> >> > > >> >> > > Is there a way to remove the filter so my Parts form can still use >> >> > > the >> >> > > lookup Combos if a user wants to explore other records >> >> > > maybe on Form Activate? >> >> > > >> >> > > I have tried a few things but my form resets to the first record >> >> > > when >> >> > > i >> >> > > remove filters with VBA >> >> > > >> >> > > Any help would be appreciated.. >> >> > >> >> > >> >> > >> >> >>
|
|
Close form first duh (i feel stupid)
Problems solved Thank you so much
"Jeanette Cunningham" wrote:
[Quoted Text] > The easiest option would to be to close F_InventoryTransactions (if it is > open) before you open it. > > Private Sub PartNumber_Textbox_DblClick(Cancel As Integer) > On Error GoTo Err_PartNumber_Textbox_DblClick > Dim stDocName As String > stDocName = "F_InventoryTransactions" > > If CurrentProject.AllForms(stDocName).IsLoaded Then > DoCmd.Close acForm, stDocName > End If > > DoCmd.OpenForm stDocName, , , , , , Me![ID] > > Exit_PartNumber_Textbox_DblClick: > Exit Sub > > Err_PartNumber_Textbox_DblClick: > MsgBox Err.Description > Resume Exit_PartNumber_Textbox_DblClick: > End Sub > > > > "Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message > news:402166B4-EE0B-411D-8F3B-1A2063EB80ED[ at ]microsoft.com... > > Jeanette im sorry but i just cant quite get it to work > > A little more info. > > datasheet form that displays a filtered set of records named F_BrowseParts > > if the PartNumber_textbox is double clicked i used your code to open > > F_InventoryTransactions and set a record with Openargs=Me![id] > > > > Private Sub PartNumber_Textbox_DblClick(Cancel As Integer) > > On Error GoTo Err_PartNumber_Textbox_DblClick > > > > Dim stDocName As String > > stDocName = "F_InventoryTransactions" > > DoCmd.OpenForm stDocName, , , , , , Me![ID] > > > > Exit_PartNumber_Textbox_DblClick: > > Exit Sub > > > > Err_PartNumber_Textbox_DblClick: > > MsgBox Err.Description > > Resume Exit_PartNumber_Textbox_DblClick: > > End Sub > > > > Then I set up the F_Inventorytransactions to accept the openargs with > > > > Private Sub Form_Load() > > If Len(Me.OpenArgs & vbNullString) > 0 Then > > Me.SelectByPNID_Combo = Nz(Me.OpenArgs, 0) > > Call SelectByPNID_Combo_AfterUpdate > > End If > > > > End Sub > > > > However if the F_Inventorytransactions is allready open nothing happens > > i would like to be able to open the F_inventorytransactions from a > > switchboard, and from the Browse records form, maybe a > > If Not IsLoaded("F_InventoryTransactions") Then is needed somewhere in my > > PartNumber_Textbox_DblClick Code but i cant figure how to get it in there. > > > > Any help would be appreciated > > Barry > > > > "Jeanette Cunningham" wrote: > > > >> If the form is already open, you can set the value of the combo directly > >> from the other form. > >> Run code something like this on the form with the combo, not sure which > >> event would be best for this: > >> > >> > >> Me.NameOfCombo = Forms!frmOtherForm.NameOfControlWithPKID > >> Call NameOfCombo_AfterUpdate > >> > >> > >> Replace the obvious with your control and form names. > >> > >> Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia > >> > >> > >> "Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message > >> news:24CC48F6-41BC-42E4-AE31-C34A56C157AF[ at ]microsoft.com... > >> > Jeanette > >> > I have discovered this code doesnt work if the form is allready opened, > >> > Can > >> > you help me with the code on this?? maybe on load or on activate?? > >> > > >> > Thanks > >> > > >> > "Barry A&P" wrote: > >> > > >> >> Jeanette Thank you so much for the great Fix....... > >> >> > >> >> "Jeanette Cunningham" wrote: > >> >> > >> >> > Hi Barry A&P, > >> >> > one way I sometimes use is: > >> >> > Instead of opening the search form with a where clause, pass the > >> >> > PartNumberID in the OpenArgs. > >> >> > In the load event retrieve the value of the ID. > >> >> > Assuming the ID is a number and not a string: > >> >> > > >> >> > If Len(Me.OpenArgs & vbNullString) >0 Then > >> >> > Me.NameOfCombo = Nz( Me.OpenArgs,0) > >> >> > Call NameOfCombo_AfterUpdate > >> >> > End If > >> >> > > >> >> > Replace the obvious with your control names. > >> >> > > >> >> > > >> >> > Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia > >> >> > > >> >> > > >> >> > "Barry A&P" <BarryAP[ at ]discussions.microsoft.com> wrote in message > >> >> > news:A2114F8D-A5B8-4732-ABC0-0A6E32C499DC[ at ]microsoft.com... > >> >> > >I have a unbound combo box used to find a record on a My form > >> >> > >F_Parts > >> >> > > it uses the rs.FindFirst "[PartNumberID] code that the Wizard > >> >> > > Supplies on > >> >> > > the after Update, > >> >> > > > >> >> > > I also have code on my forms "On Current" that keeps the combo > >> >> > > displaying > >> >> > > the correct info if navigation buttons are used > >> >> > > Me.SelectByPNID_Combo > >> >> > > = > >> >> > > Me.PartNumberID > >> >> > > > >> >> > > the issue i am now having is Code from my F_search that opens this > >> >> > > form > >> >> > > uses > >> >> > > a Where statement to open this form so my F_Parts is opened > >> >> > > "Filtered" and > >> >> > > the find record combos no longer work and display wierd data that > >> >> > > is > >> >> > > misleading. > >> >> > > > >> >> > > Here is the code from my search Form > >> >> > > > >> >> > > Private Sub OpenParts_Click(Cancel As Integer) > >> >> > > On Error GoTo Err_OpenParts_Click > >> >> > > > >> >> > > Dim stDocName As String > >> >> > > Dim stLinkCriteria As String > >> >> > > > >> >> > > stDocName = "F_Parts" > >> >> > > > >> >> > > stLinkCriteria = "[PartNumberID]=" & Me![ID] > >> >> > > DoCmd.OpenForm stDocName, , , stLinkCriteria > >> >> > > > >> >> > > Exit_OpenParts_Click: > >> >> > > Exit Sub > >> >> > > > >> >> > > Err_OpenParts_Click: > >> >> > > MsgBox Err.Description > >> >> > > Resume Exit_OpenParts_Click: > >> >> > > End Sub > >> >> > > > >> >> > > Is there a way to remove the filter so my Parts form can still use > >> >> > > the > >> >> > > lookup Combos if a user wants to explore other records > >> >> > > maybe on Form Activate? > >> >> > > > >> >> > > I have tried a few things but my form resets to the first record > >> >> > > when > >> >> > > i > >> >> > > remove filters with VBA > >> >> > > > >> >> > > Any help would be appreciated.. > >> >> > > >> >> > > >> >> > > >> > >> > >> > > > > >
|
|
|