FindRecord

CanWest

Registered User.
Local time
Today, 06:00
Joined
Sep 15, 2006
Messages
272
I have tried to get this working for two days now and I am pulling my hair out. Here is the scenario. I have a form called frm_MainMenu which has a subform called sfrm_Company

There is a search section on that subform that displayes its results in a popup continuous form called pfrm_CompanyList

There is a button beside each result that I want to first move the subform on the mainform to the appropriate company and then close the popup form

Take a look at this code for the button

Code:
Private Sub cmdOpenCompany_Click()

    Forms!frm_MainMenu!sfrm_Company.SetFocus
    Forms![frm_MainMenu]![sfrm_Company].Form![CompamyID].SetFocus
    
    DoCmd.FindRecord Forms!pfrm_CompanyList!CompanyID, , , , , acCurrent
    DoCmd.Close acForm, "pfrm_CompanyList"
    
    Forms!frm_MainMenu!tabMainMenu.SetFocus
    Forms!frm_MainMenu.tabMainMenu = 1
End Sub


Any help would be greatly appreciated as I am stumped. I have search here and elsewhere with no luck.
 
Just to clarify your FindRecord code, you are looking for any occurance of ComapanyID on your subform that matched the CompanyID on the pop up form?

Incidentally, your code has a possible typo. You refer to CompanyID in the FindRecord line BUT CompamyID in the set focus line.
 
Just to clarify your FindRecord code, you are looking for any occurance of ComapanyID on your subform that matched the CompanyID on the pop up form?

Incidentally, your code has a possible typo. You refer to CompanyID in the FindRecord line BUT CompamyID in the set focus line.

Thanks for pointing that out. It was an issue with the field being named CompanyID but the object being named CompamyId. However it still does not work. I keep getting runtime error 2162
 
What is the exact error you are getting there CanWest?
 
What is the exact error you are getting there CanWest?

Run-Time error 2162
A macro set to one of the current field's properties failed because of an error in a FindRecord action argument

Hope this helps
 

Users who are viewing this thread

Back
Top Bottom