Results 1 to 11 of 11
  1. #1
    chiefmsb is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2006
    Location
    rockville centre, ny
    Posts
    23

    linking forms

    I have a form with info from a table with an autogenerted id as the key. i want a button that will open another form and give the new form(based on a different table) the id automatically put into an id field in the new form. Is this the best way to link these tables and do i put code on the button opening the new form under on click and would the code be on click: infoID=newformID. I am building a relationship between these two id fields as well.
    thanks, mark

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,621
    The code would be:
    DoCmd.OpenForm "formname", , ,"new form ID fieldname=" & Me.formID

    You might explore form/subform arrangement for this.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    chiefmsb is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2006
    Location
    rockville centre, ny
    Posts
    23
    I set up the command button in the form design view. It lists the condition ="[InfoID]=" & [ID].

    This will show any items in the second (I call it exam) table that are linked to that ID. If there are no exam items for that user ID then a blank form opens up. I want this blank form to have be default the ID in the InfoID field of the exam database automatically. I am thinking that if there is no record and I am adding one that when I click on or tab to that field then an event should occur where this number is inserted into the InfoID field. Should I put code in the On click area or After Update or where and what should I use. Also I replaced the [ID] with me.ID and I get an error message that the object dowsn't contain the Automation object 'Me.'
    thanks , mark

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,621
    Then the code would have to first check the database to see if there are exam items and open form filtered to those records, otherwise open form to NewRecord and populate the ID field with the ID value passed in code. Still think would be worth exploring form/subform setup. Can avoid a lot of coding with that approach.

    If code is behind button then would be Click event, behind a text/combo/list box would be AfterUpdate. Post your entire code procedure for analysis. Where did you put the expression: ="[InfoID]=" & [ID]?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    chiefmsb is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2006
    Location
    rockville centre, ny
    Posts
    23
    I put the expression on the button to open the form. I did this via the wizard when creating the button. There is no code other than what that button generated.If there is no exam then the exam form comes up new. I want to tab or click on the InfoID field that is connected to the ID field in the info table and have it take the value of the person I am using in the original info table.
    thanks, mark

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,621
    I don't use the wizards so not quite sure what was built. What do you mean by 'on the button'? The expression ="[InfoID]=" & [ID] is in a property of the button or in a macro or in VBA procedure? I need to know exactly where it is located. Code will have to be customized to grab the ID from the other form. Something like:
    If IsNull(Me.ID) Then
    Me.ID = Form_otherformname.IDcontrolname.
    End If

    If you want to attach project I will look at it.

    Again, form/subform arrangement could eliminate the need for more code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    chiefmsb is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2006
    Location
    rockville centre, ny
    Posts
    23

    cant upload

    The database is bigger than the 500 kb limit. In the command button under OnClick it opens the form and under where condition it says =="[InfoID]=" & [ID].
    This basically shows the exam form with only the records pertaining to the patient being used. I could tackle this in several ways one being if there are records in the exam table by clicking new record if there is someplace to put code to make the InfoID = to the ID used for the patient that we were orginally using. need to get the InfoID = ID of the patient. I was hoping some code under OnClick of the InfoID field would be able to do this.
    thanks, mark

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,621
    You can zip the project with Windows Compression and attach a much larger file. Be sure to run Compact & Repair before uploading, zipped or not. Make sure there is no confidential data. I am sure code can do what you want but I really need to see the project before I can advise further. Or at least just the forms and tables of this issue.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    chiefmsb is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2006
    Location
    rockville centre, ny
    Posts
    23
    I tried using a subform and it did everything I wanted. The only problem is that these two forms are going to be quite big when I am done with them. Can this be done using tabs or any other suggestions.
    thanks, mark

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,621
    Yes, a tab control can be used to organize controls into more manageable groupings. You can even put a subform on a tab control. I have one little project that has a main form with a tab control and on the tab is a mixture of text, combo, list boxes, and subforms (subforms also have subforms). This is the only form structure that users interact with and no code is involved.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    chiefmsb is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2006
    Location
    rockville centre, ny
    Posts
    23
    I did this and all seems to be working well. thanks, mark

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Linking two forms
    By JeffG3209 in forum Forms
    Replies: 3
    Last Post: 05-09-2011, 12:26 PM
  2. Linking forms
    By warrigal in forum Database Design
    Replies: 2
    Last Post: 04-07-2011, 05:12 PM
  3. Linking forms (I think!!!)
    By Sleepymum in forum Forms
    Replies: 5
    Last Post: 02-21-2011, 07:28 AM
  4. Linking Forms
    By glasgowlad1999 in forum Forms
    Replies: 1
    Last Post: 02-02-2011, 09:35 AM
  5. Linking Forms
    By dalton in forum Forms
    Replies: 1
    Last Post: 05-30-2010, 11:23 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums