Results 1 to 5 of 5
  1. #1
    bbrazeau is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    101

    one to one annomly or built in feature of access?

    I have a one to one relationship between tables Rfqs and Quotes.
    I have a form "frmRfq" that has a button "cmdNewQuote" it opens the "frmQuotesAdd" with:

    Private Sub cmdNewQuote_Click()
    If DCount("QuoteID", "tblQuotes", "QuoteID =" & Me.RfqID) = 0 Then
    DoCmd.OpenForm "frmQuotesAdd", , , , acFormAdd
    Else
    MsgBox ("This Rfq already has a quote")


    End If
    End Sub

    When I run the code I get a dialog box similar to a parameter query asking for the Rfq. My question is...Is this something access does automatically with a one to one relationship or is there a mistake in my code? P.S. I use the On Load event of "frmQuotesAdd" to set the QuoteId to the current RfqId.

    Private Sub Form_Load()
    Me.QuoteID = Forms!frmRfqs!RfqID
    Me.Form.AllowAdditions = False
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The parameter prompt usually means something is spelled wrong. It's Access' way of telling you it can't find something.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by bbrazeau View Post
    I have a one to one relationship between tables Rfqs and Quotes.
    I have a form "frmRfq" that has a button "cmdNewQuote" it opens the "frmQuotesAdd" with:

    Private Sub cmdNewQuote_Click()
    If DCount("QuoteID", "tblQuotes", "QuoteID =" & Me.RfqID) = 0 Then
    DoCmd.OpenForm "frmQuotesAdd", , , , acFormAdd
    Else
    MsgBox ("This Rfq already has a quote")
    End If
    End Sub

    When I run the code I get a dialog box similar to a parameter query asking for the Rfq. My question is...Is this something access does automatically with a one to one relationship or is there a mistake in my code? P.S. I use the On Load event of "frmQuotesAdd" to set the QuoteId to the current RfqId.

    Private Sub Form_Load()
    Me.QuoteID = Forms!frmRfqs!RfqID
    Me.Form.AllowAdditions = False
    End Sub

    Since the two tables have a one to one relationship, why do you have two tables? One record in tblRfqs can have one, and only one, record in tblQuotes.

    Or why don't you have a query that joins both tables and display the fields on one form? No need to waste time with DCount() or opening another form.

    It would be different if it was a one to many relationship, where there could be more than one quote for each Rfq.

  4. #4
    bbrazeau is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    101

    1 to 1 reason

    The reason I chose to split Rfqs and Quotes out into 2 tables are:
    1).They will be created by different people at different times and will each have an author and date fields of who made what and when.
    2). Quotes will be a complex table and form with links to other tables that would have made working with Rfqs that much tougher. I'm not that good at programing.
    3). I will eventually make a query that pulls Quotes and other tables together, and maybe have Rfqs as a subform, but I want to keep Quotes (filled in by hopefully a skilled user) seperated from Rfqs (filled in by someone of potentially far less skill and potentially a far greater propensity for messing something up.

    I just made a simlified example and everything works fine. I'll find my mistake in the code. Will "DCount" put that much of a performance hit on my database?

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    As you're using it, the DCount shouldn't be a problem. They're worst when used in queries.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 04-13-2011, 10:23 AM
  2. Fieldset and Legend feature in Access?
    By ibmichael in forum Forms
    Replies: 1
    Last Post: 10-28-2010, 03:15 PM
  3. Comparison Feature Help
    By Kapelluschsa in forum Access
    Replies: 2
    Last Post: 10-25-2010, 06:43 AM
  4. Replies: 26
    Last Post: 09-27-2010, 09:48 PM
  5. Help with a search feature or combo box
    By jmanis in forum Forms
    Replies: 14
    Last Post: 07-06-2010, 06:38 AM

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