Returning from Popup, Combo Box search feature does not work

psalmon

Registered User.
Local time
Today, 14:11
Joined
Jun 20, 2005
Messages
21
I have a form with a combo box to search for a specific record. This works beautifully until I navigate to a popup window and return to the main form. Once I return, the combo box does not find the record I try to search for.

I am sure I am missing something small, I hope someone can help me.

Thanks,
Pat
 
I will elaborate. From the main form I have a button that opens the second form (not a subform) and displays records that match the part # from the main form. The second form displays multiple detail recordss for that part # and I have a button to select a different record or return to the form.

This is the code to go from the main form to the second form, created by the Wizard.


Private Sub cmdNCRHistory_Click()
On Error GoTo Err_cmdNCRHistory_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = %22frmNCRDetails%22

stLinkCriteria = %22[P/N]=%22 & %22'%22 & Me![txtMaterialNumber] & %22'%22
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdNCRHistory_Click:
Exit Sub

Err_cmdNCRHistory_Click:
MsgBox Err.Description
Resume Exit_cmdNCRHistory_Click

End Sub



to return to the main form, I have, (again created by the Wizard). When I use this option my combo box is still functional.


Private Sub cmdReturn_Click()
On Error GoTo Err_cmdReturn_Click


DoCmd.Close

Exit_cmdReturn_Click:
Exit Sub

Err_cmdReturn_Click:
MsgBox Err.Description
Resume Exit_cmdReturn_Click

End Sub



To select a different record and return to the main screen with this record displayed I have: (Wizard again)


Private Sub cmdReturnToNCR_Click()
On Error GoTo Err_cmdReturnToNCR_Click

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = %22frmNCR%22

stLinkCriteria = %22[NCRNumber]=%22 & Me![txtNCRNumber]
DoCmd.Close
DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria


Exit_cmdReturnToNCR_Click:
Exit Sub

Err_cmdReturnToNCR_Click:
MsgBox Err.Description
Resume Exit_cmdReturnToNCR_Click

End Sub



After this the combo box can no longer find any records, although the drop down list shows them. I suspect it has something to do with how I returned to the main form by selecting a specific record, highlighted in bold above.

Any help will be appreciated.
Thanks,
Pat
 
I copied and pasted into the window and the double quotes translated into %22. Odd. Anyway that is what they should be.
Pat
 
It seems like it is returning to the main form in a different way than it is initially called.

What I would like to do, (maybe I'm way off base with my method), is from my main form, navigate to another form based on the record that is currently displayed. From there I would like the option of just returning to the main form and not change the current record, (the code I am using works) OR return to the main form and move to another record that is selected on the secondary form. When I return to the main form I would like the search and navigation buttons to work as before.

Has anyone done something like this? What would be the best way to accomplish it?

Thanks,
Pat
 
I have changed the code to


stLinkCriteria = Me![txtNCRNumber]
DoCmd.Close

DoCmd.OpenForm "frmNCR", acNormal, "", "", acEdit, acNormal
[Forms]![frmNCR]![cboNCRNumber] = stLinkCriteria
[Forms]![frmNCR]!cboNCRNumber.SetFocus


This closes the secondary form and puts the NCR Number into the search combo box. It doesn't perform the search if I hit "Enter", but if I click the dropdown of the combo box, where it defaults to the value I have passed, I can click to select and naviagate to the correct record and any other I wish to.

So I now just need to know how to get the combo box to trigger when I return to the main form. Getting closer!! Any ideas?

Thanks,
Pat
 

Users who are viewing this thread

Back
Top Bottom