PC Review


Reply
Thread Tools Rate Thread

Creating a Message Box

 
 
=?Utf-8?B?Z29waQ==?=
Guest
Posts: n/a
 
      26th Jun 2006
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.

 
Reply With Quote
 
 
 
 
Al Camp
Guest
Posts: n/a
 
      26th Jun 2006
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" <(E-Mail Removed)> wrote in message
news:C472B749-2AC4-447F-AF00-(E-Mail Removed)...
> 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.
>



 
Reply With Quote
 
=?Utf-8?B?T2ZlciBDb2hlbg==?=
Guest
Posts: n/a
 
      26th Jun 2006
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.
>

 
Reply With Quote
 
=?Utf-8?B?Z29waQ==?=
Guest
Posts: n/a
 
      27th Jun 2006
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.
> >

 
Reply With Quote
 
=?Utf-8?B?Z29waQ==?=
Guest
Posts: n/a
 
      30th Jun 2006
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.
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to change a message subject without creating new message =?Utf-8?B?TGd1?= Microsoft Outlook Discussion 1 7th Jul 2005 07:37 PM
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau Microsoft ASP .NET 0 1st Jun 2005 03:36 PM
Warning message when creating a message in Outloo J. Alyn Microsoft Outlook Discussion 0 7th Jun 2004 05:28 PM
Error message creating new message (memory) Mark Smith Microsoft Windows 2000 2 2nd Jun 2004 06:25 AM
ActivX error message when creating new email message. Cleo Jones Microsoft Outlook 0 9th Dec 2003 06:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:19 AM.