Results 1 to 3 of 3
  1. #1
    Jerry8989 is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2009
    Posts
    27

    Question One to Many query for a Form

    I have two tables (user and notes). It is a 1 to Many relationship.


    I might have 0 notes for a user or I might have 5 separate rows of notes for 1 user.

    I have a form that I want to display the user information and then show an indicator if this user has any notes so I plan on using a checkbox.

    My problem is that I can't use distinct in my query or else my form becomes uneditable. Other then creating a seperate distinct list of id & notes table how can I get around this?

    Thank you for any help pointing me in the right direction

  2. #2
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    If you only want to show the user that the currently selected person has notes attached to them then you may be able to simply do a look up or a count. Count may be better.

    OnCurrent Event

    Code:
     
    Dim xMany As Integer
     
    xMany = Nz(DCount("*","TblNotes","UserID=" & Me.TxtUserId),0)
     
    Me.CmdNotes.Caption = xMany & " Note(s) Found"
    This is aircode and untested, likewise the control names are used for brevity.


    David

  3. #3
    Jerry8989 is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2009
    Posts
    27
    dcrake,
    Thank you so much. What you posted reminded me that I don't have to tie everything using the data source query. I created a function within my module that I use as my data source for my checkbox field. I take the id from that row and pass it in and it returns me back a 0 or -1 and the checkbox appears correctly. Thank you again so much for sparking that idea into my head.

    Thank You
    Jerry

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

Similar Threads

  1. Query and form help
    By KevinH in forum Access
    Replies: 3
    Last Post: 09-04-2009, 08:10 AM
  2. Query To Form
    By RyanPRomero in forum Queries
    Replies: 1
    Last Post: 08-29-2009, 07:58 PM
  3. Use form data in a query
    By Zholt in forum Forms
    Replies: 2
    Last Post: 05-13-2009, 07:59 PM
  4. Update Query from Form
    By ste_pie87 in forum Queries
    Replies: 2
    Last Post: 04-26-2009, 07:22 PM
  5. Query expression for form
    By pjacob in forum Forms
    Replies: 1
    Last Post: 10-10-2006, 09:12 PM

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