Welcome to SPN

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

Sign Up Now!

Creating a Message Box

Discussion in 'Information Technology' started by gopi, Jul 28, 2006.

  1. gopi

    gopi
    Expand Collapse
    Guest

    Hi,
    I have a primary key field. but whenever i enter the same details twice in
    that field it doesnt give me an message telling me that i have entered the
    same detail twice, as this field must be unique, instead it closes the form
    and does not save.

    Is there anyway i can get the database to prompt me with a message telling
    me that i have allready entered the same detail before?

    let me know if any other details is needed.

    Thanks in advanced.
     
  2. Loading...

    Similar Threads Forum Date
    Canada Ottawa weighs creating ambassador for religious freedom Breaking News Oct 4, 2011
    India SGPC Accused of Creating a Row Breaking News Jan 20, 2011
    Pacific International Gathering of Young Sikhs Focuses on Creating Good Citizens Breaking News Jan 8, 2011
    Are We Creating New Devtas? Sikh Sikhi Sikhism Aug 21, 2009
    Sikh News Sharif warns against creating instability in Punjab (Express India) Breaking News Sep 19, 2008

  3. Al Camp

    Al Camp
    Expand Collapse
    Guest

    gopi,
    How do you have the key field defined in your table? Give details...
    It should be Indexed No Duplicates as well as Key.

    --
    hth
    Al Camp
    Candia Computer Consulting - Candia NH
    http://home.comcast.net/~cccsolutions

    "gopi" <gopi@discussions.microsoft.com> wrote in message
    news:C472B749-2AC4-447F-AF00-DF8D35295C31@microsoft.com...
    > Hi,
    > I have a primary key field. but whenever i enter the same details twice in
    > that field it doesnt give me an message telling me that i have entered the
    > same detail twice, as this field must be unique, instead it closes the form
    > and does not save.
    >
    > Is there anyway i can get the database to prompt me with a message telling
    > me that i have allready entered the same detail before?
    >
    > let me know if any other details is needed.
    >
    > Thanks in advanced.
    >
     
  4. Ofer Cohen

    Ofer Cohen
    Expand Collapse
    Guest

    On the Before Update event of the form you can write the code that check if
    the record already exist

    Private Sub Form_BeforeUpdate(Cancel As Integer)

    If Me.KeyFieldInTheForm<> Me.KeyFieldInTheForm.OldValue Then
    If DCount("*", "TableName", "KeyField =" & Me.KeyFieldInTheForm) > 0 Then
    MsgBox "Record exist"
    Cancel = True ' wont save the record
    End If
    End If
    End Sub

    ================
    If the key field is string then change the Dcount to
    If DCount("*", "TableName", "KeyField ='" & Me.KeyFieldInTheForm & "'") > 0
    Then


    --
    Good Luck
    BS"D


    "gopi" wrote:

    > Hi,
    > I have a primary key field. but whenever i enter the same details twice in
    > that field it doesnt give me an message telling me that i have entered the
    > same detail twice, as this field must be unique, instead it closes the form
    > and does not save.
    >
    > Is there anyway i can get the database to prompt me with a message telling
    > me that i have allready entered the same detail before?
    >
    > let me know if any other details is needed.
    >
    > Thanks in advanced.
    >
     
  5. gopi

    gopi
    Expand Collapse
    Guest

    Hi, thanks for your help, but code doesnt seem to work. I mustve adapted the
    code in the wrong way.

    The Field is basically called 'UpgradeNumber', as a Number format. It is
    reuqired and have had it indexed, i.e. No Duplicates. The table name is
    called SouthTracker.

    How would i put these details into the code you have given me?

    Thanks for your help.

    "Ofer Cohen" wrote:

    > On the Before Update event of the form you can write the code that check if
    > the record already exist
    >
    > Private Sub Form_BeforeUpdate(Cancel As Integer)
    >
    > If Me.KeyFieldInTheForm<> Me.KeyFieldInTheForm.OldValue Then
    > If DCount("*", "TableName", "KeyField =" & Me.KeyFieldInTheForm) > 0 Then
    > MsgBox "Record exist"
    > Cancel = True ' wont save the record
    > End If
    > End If
    > End Sub
    >
    > ================
    > If the key field is string then change the Dcount to
    > If DCount("*", "TableName", "KeyField ='" & Me.KeyFieldInTheForm & "'") > 0
    > Then
    >
    >
    > --
    > Good Luck
    > BS"D
    >
    >
    > "gopi" wrote:
    >
    > > Hi,
    > > I have a primary key field. but whenever i enter the same details twice in
    > > that field it doesnt give me an message telling me that i have entered the
    > > same detail twice, as this field must be unique, instead it closes the form
    > > and does not save.
    > >
    > > Is there anyway i can get the database to prompt me with a message telling
    > > me that i have allready entered the same detail before?
    > >
    > > let me know if any other details is needed.
    > >
    > > Thanks in advanced.
    > >
     
  6. gopi

    gopi
    Expand Collapse
    Guest

    Hi, thanks for your help, but code doesnt seem to work. I mustve adapted the
    code in the wrong way.

    The Field is basically called 'Upgrade Number', as a Number format in the
    table. It is
    reuqired and have had it indexed, i.e. No Duplicates. The table name is
    called SouthTracker. However, on the form the field is called 'Text228', and
    the form name is South_Tracker.

    How would i put these details into the code you have given me?

    Thanks for your help.


    "Ofer Cohen" wrote:

    > On the Before Update event of the form you can write the code that check if
    > the record already exist
    >
    > Private Sub Form_BeforeUpdate(Cancel As Integer)
    >
    > If Me.KeyFieldInTheForm<> Me.KeyFieldInTheForm.OldValue Then
    > If DCount("*", "TableName", "KeyField =" & Me.KeyFieldInTheForm) > 0 Then
    > MsgBox "Record exist"
    > Cancel = True ' wont save the record
    > End If
    > End If
    > End Sub
    >
    > ================
    > If the key field is string then change the Dcount to
    > If DCount("*", "TableName", "KeyField ='" & Me.KeyFieldInTheForm & "'") > 0
    > Then
    >
    >
    > --
    > Good Luck
    > BS"D
    >
    >
    > "gopi" wrote:
    >
    > > Hi,
    > > I have a primary key field. but whenever i enter the same details twice in
    > > that field it doesnt give me an message telling me that i have entered the
    > > same detail twice, as this field must be unique, instead it closes the form
    > > and does not save.
    > >
    > > Is there anyway i can get the database to prompt me with a message telling
    > > me that i have allready entered the same detail before?
    > >
    > > let me know if any other details is needed.
    > >
    > > Thanks in advanced.
    > >
     

Share This Page