Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Multiple Record Returned Alert(2)

Discussion in 'Information Technology' started by ckendricks7@yahoo.com, Jul 28, 2006.

  1. ckendricks7@yahoo.com

    ckendricks7@yahoo.com
    Expand Collapse
    Guest

    This is my second time posting this problem:
    have a form that pulls up individual client records utilizing a
    parameter query as it's Record Source. I want to open a MsgBox if more

    than one client record is returned. I know that I can use the DCount
    function and a field from the returned data (like the primary key) to
    somehow trigger a MsgBox, but I just can't seem to get it to work.

    Maybe I should note that the primary form contains a subform with four
    tab controls.

    It was suggested that I try the following procedure in response to the
    Form_Load event:

    Private Sub Form_Load()
    If Me.Recordset.RecordCount > 1 Then
    MsgBox Me.Recordset.RecordCount _
    & " records were returned" _
    , , "RecordCount"
    Else
    MsgBox "one record was returned" _
    , , "One record"
    End If
    End Sub

    When I tried this procedure the MsgBox "one record was returned" comes
    up every time. Even if I enter a phone number (which I use as the
    criteria for the client search), for which I know there are multiple
    records (husband and wife clients). However I noticed that if after I
    give it a phone number for which I know there are multiple records, and
    it responds with the "one record was returned" MsgBox, if I immediately
    go to Design mode, and then back to Form mode, THEN the correct MsbBox
    is displayed ("2 records were returned"). I have tried tying the code
    to several different form events, with the same results

    What am I doing wrong???
     
  2. Loading...


  3. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    See:
    VBA Traps: Working with Recordsets
    at:
    http://allenbrowne.com/ser-29.html

    You have fallen for the 2nd one.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    <ckendricks7@yahoo.com> wrote in message
    news:1148908142.160120.83710@j73g2000cwa.googlegroups.com...
    > This is my second time posting this problem:
    > have a form that pulls up individual client records utilizing a
    > parameter query as it's Record Source. I want to open a MsgBox if more
    >
    > than one client record is returned. I know that I can use the DCount
    > function and a field from the returned data (like the primary key) to
    > somehow trigger a MsgBox, but I just can't seem to get it to work.
    >
    > Maybe I should note that the primary form contains a subform with four
    > tab controls.
    >
    > It was suggested that I try the following procedure in response to the
    > Form_Load event:
    >
    > Private Sub Form_Load()
    > If Me.Recordset.RecordCount > 1 Then
    > MsgBox Me.Recordset.RecordCount _
    > & " records were returned" _
    > , , "RecordCount"
    > Else
    > MsgBox "one record was returned" _
    > , , "One record"
    > End If
    > End Sub
    >
    > When I tried this procedure the MsgBox "one record was returned" comes
    > up every time. Even if I enter a phone number (which I use as the
    > criteria for the client search), for which I know there are multiple
    > records (husband and wife clients). However I noticed that if after I
    > give it a phone number for which I know there are multiple records, and
    > it responds with the "one record was returned" MsgBox, if I immediately
    > go to Design mode, and then back to Form mode, THEN the correct MsbBox
    > is displayed ("2 records were returned"). I have tried tying the code
    > to several different form events, with the same results
    >
    > What am I doing wrong???
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page