Open a form to a specific record, based on a control on another form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Bentler
    New Member
    • Mar 2008
    • 4

    Open a form to a specific record, based on a control on another form

    I have a form that is locked for editing, adding or deleting. Through the use of a command button I open another form, that allows editing, plus allows the user to other areas of the database, through command buttons.
    When I click the command button I want to open the second form displaying the CompanyName and information from the first form (the record I had displayed on first form, but open for editing.
    On the second form I have a command button that when clicked allows the user to edit the insurance date information of the Company. I would like this form to display the CompanyName from the original form, plus the insurance date.

    Right now as I open each form, I have to do a find to get to the record I had displayed on my original form.
    So far I am not sure how to go about this so have no code...Any suggestions
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    Originally posted by Martin Bentler
    I have a form that is locked for editing, adding or deleting. Through the use of a command button I open another form, that allows editing, plus allows the user to other areas of the database, through command buttons.
    When I click the command button I want to open the second form displaying the CompanyName and information from the first form (the record I had displayed on first form, but open for editing.
    On the second form I have a command button that when clicked allows the user to edit the insurance date information of the Company. I would like this form to display the CompanyName from the original form, plus the insurance date.

    Right now as I open each form, I have to do a find to get to the record I had displayed on my original form.
    So far I am not sure how to go about this so have no code...Any suggestions
    txtSecondFormSe arch.text = FirstFormName!t xtCompanyName.T ext

    I have no idea if this is what your looking for but this is how you can get values from controls on a different form then the one your working with.

    Otherwise you can also use functions to pass your values like parameters from one function to the next. This will work if your functions are declared globally and in a Module as well as the variables you are using. Otherwise the above should work.

    Comment

    • Martin Bentler
      New Member
      • Mar 2008
      • 4

      #3
      Originally posted by jeffstl
      txtSecondFormSe arch.text = FirstFormName!t xtCompanyName.T ext

      I have no idea if this is what your looking for but this is how you can get values from controls on a different form then the one your working with.

      Otherwise you can also use functions to pass your values like parameters from one function to the next. This will work if your functions are declared globally and in a Module as well as the variables you are using. Otherwise the above should work.
      Well, this gives me a direction.

      DoCmd.OpenForm "frmEditCompany List", acNormal, , , acFormEdit, acWindowNormal
      txtfrmEditCompa nyListSearch.Te xt = frmCompanyList! txtCompanyName. Text
      DoCmd.Close acForm, "frmCompanyList ", acSaveYes

      But I don't have it right yet. I appreciate your help.

      Comment

      • jeffstl
        Recognized Expert Contributor
        • Feb 2008
        • 432

        #4
        Originally posted by Martin Bentler
        Well, this gives me a direction.

        DoCmd.OpenForm "frmEditCompany List", acNormal, , , acFormEdit, acWindowNormal
        txtfrmEditCompa nyListSearch.Te xt = frmCompanyList! txtCompanyName. Text
        DoCmd.Close acForm, "frmCompanyList ", acSaveYes

        But I don't have it right yet. I appreciate your help.
        OK
        Is this access? If you are working with VBA in access you might get a better way to do this on the access forums. Also I'm not 100% sure but I thought there was a form wizard that lets you build out a function exactly as you are describing (opening a form on a record based on a value from the current form).

        Anyway just wanted to point out too that I think this:

        txtfrmEditCompa nyListSearch.Te xt = frmCompanyList! txtCompanyName. Text

        Should be in you Form_Load event on the frmEditCompanyL istSearch Form probably.

        Comment

        • Martin Bentler
          New Member
          • Mar 2008
          • 4

          #5
          Originally posted by jeffstl
          OK
          Is this access? If you are working with VBA in access you might get a better way to do this on the access forums. Also I'm not 100% sure but I thought there was a form wizard that lets you build out a function exactly as you are describing (opening a form on a record based on a value from the current form).

          Anyway just wanted to point out too that I think this:

          txtfrmEditCompa nyListSearch.Te xt = frmCompanyList! txtCompanyName. Text

          Should be in you Form_Load event on the frmEditCompanyL istSearch Form probably.
          Thanks, I have it figured. And thought I was in a VBA forum, guess I was not paying attention.

          Comment

          Working...