Linking tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Newbie23
    New Member
    • Jan 2009
    • 25

    #1

    Linking tables

    Hi

    Please can someone help me?!! For some reason I cant get my two data input forms to link on a ID value. I'm sure I have done this before, but for some reason I can get it to work and im ready to pull my hair out!!!

    --Customer table
    *AccID
    Name
    Contact Address etc

    --Properties table
    *PropID
    AccID
    Address etc

    I have two tables, Customers and Properties (one to many, linked via AccID), I then have a form for each. I want the user to input customer details then (via a button) go to the property form to add a property for that customer. I dont want the user to see the AccID field in the properties form (I want it to be linked to AccID on the customers form and automatically populated).

    Any help would be FANTASTIC!!
    Many Thanks
    Jane
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    DoCmd.OpenForm "Properties Form Name", , , , acFormAdd
    Forms("Properti es Form Name")![AccID] = AccID

    You can have AccID locked/hidden on the properties form, one you see that it is getting the correct value.

    Comment

    • Newbie23
      New Member
      • Jan 2009
      • 25

      #3
      Thank you I have it working now.

      also wonder if you can help me with this.
      When I open a create customer account form, I want the main menu form to close, same as when I close/cancel the new customer account form I want it to close then open the main menu. (as well as ask the user if they are sure?)

      This seems really simple stuff but i cant get it working !!!!!! aaarrgghhh!! ive taken code from a prev db i've done (which works and it doesnt work the same on my current one!!! im sure its something daft im not getting!

      Comment

      • ChipR
        Recognized Expert Top Contributor
        • Jul 2008
        • 1289

        #4
        It sounds like you could set your new form to modal rather than close and then open your other form. That prevents users from doing anything to other forms while this one is open. It's on the Form Properties -> Other tab.

        You can put this code in your button and disable/hide the control box and close button of the form.
        Code:
        Dim iResponse as Integer
        iResponse = MsgBox("Are you sure that you want to do this?", _
            vbYesNo, "Confirmation")
        If iResponse = vbNo Then
            Exit Sub
        End If

        Comment

        Working...