Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help.. I need messae when I enter same data 1

Status
Not open for further replies.

pcwaleed

Programmer
Oct 7, 2014
29
IQ
Hello My Friends.. I had table contain tow fields ... code and name
when I apend same data to the table , the form show me message told me (the same data in the table... ghange it)..
thanks for all
 
There are a number of ways to do what you need.

My personal choice would be to check for the existence of a matching record BEFORE appending the new record into the table.
Then if a matching record was found, you could display a message in a number of ways.
1) Use a WAIT WINDOW <message>
2) Write a text message to a textbox object on the form
3) Throw up a Messagebox() with your message in it.

Your question is pretty general. What specifically do you need help with?

Good Luck,
JRB-Bldr
 
thank for your answer ,,
can you Explain me Practically
 
As I asked before - What part of it don't you understand?

* How to check for Duplicate record?
* How to display WAIT WINDOW <message>?
Look in your VFP Help for: HELP WAIT
* How to display Messagebox()?
Look in your VFP Help for: HELP Messagebox()
* How to write message into form textbox?
* How to avoid Appending new record?

Specifically what part do you need help with?

NOTE: We generally don't write fully operational Code for someone else.
That's your 'learning opportunity'.
But we give advice/suggestions to help you with your very specific issues/challenges.

Good Luck,
JRB-Bldr

 
pcwaleed,
It sounds like you have an index on the table that is preventing duplicate values in the key field. You said your table has "code" and "name" fields. (Are they the only two fields?)
Most likely "code" needs to be "unique". There are some circumstances where this can be a problem. What might be the case is that you have a "code" field that is blank (or 0). And when you create a new record, it initially populates that value at creation as blank or 0, then you have don't have a unique key, and it fails.
Have a look in your table for a blank or 0 value in the code.

It could also be a "compound index", where they are combining the values code and name together. While that's unnecessary for uniqueness, it is a mistake some developers make. So check for that as well in your table.


Best Regards,
Scott
MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."[hammer]
 
hello
yes I need check for Duplicate record , if one is Different the operation is Right
 
So did that solve it for you? You're not really clear in your reply.


Best Regards,
Scott
MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."[hammer]
 
So did that solve it for you?

We have no idea if you still need help or not.

You have not confirmed if your data table has an Index on it or not.

If not create one....
Code:
USE MyData IN 0 EXCLUSIVE
SELECT MyData
INDEX ON  code + name TAG Indx
USE

Then from your User Data Entry Form in the Valid method of your Save button...
Code:
cCode = ThisForm.txtCode.text
cName = ThisForm.txtName.text

SELECT MyData
SET ORDER TO Indx
IF SEEK(cCode + cName)
   * --- Duplicate Found ---
   < Display message to user somehow >
ELSE
   APPEND BLANK
   REPLACE Code WITH cCode,;
     Name WITH cName
ENDIF

If that still doesn't help, then you should probably spend some time with the Free, On-line VFP Tutorial Videos at:
Free VFP Tutorial Videos

Good Luck,
JRB-Bldr

 
thats i want exactly
but show me this message
Untitled_no1tvv.png


the error in the replace
Untitled_yykvtj.png


code_name and code_cut is name the fields in my table (cutinfo)

my code is
cCode = ThisForm.text1.Value
cName = ThisForm.text2.Value

SELECT cutinfo
SET ORDER TO INDX && CODE_NAME+CODE_CUT
IF SEEK(cCode + cName)
* --- Duplicate Found ---
MESSAGEBOX("jbhhkhkjhj",4,"jhgh")
ELSE
APPEND BLANK
REPLACE CODE_NAME WITH cCode,;
CODE_CUT WITH cName
ENDIF
 
What is not to know?

The error message indicates: Data Type Mismatch

That is self-explanatory.
We don't know the data table field Types that you have for Code_Name and Code_Cut.
And we don't know what the values are which populate the variables: cCode and cName.

However it is obvious that one of the variable values is not matching the Field Type of its intended data field.

As I previously recommended -- Go over to the Free, Online VFP Tutorial videos at: Free VFP Tutorial Videos
and spend some time learning how to use Visual Foxpro.

Among those videos you might want to focus spending time looking at:
Building a Simple Application - Pt. 2

In this video we complete the User (staff) managment forms. One highlight of this video is the use of the Visual FoxPro Debugger.

Good Luck,
JRB-Bldr
 
hello
i solved this error
i rename the text properties in the form from character to numeric and every think is right
thank 4 all
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top