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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to control what is writen to the database

Status
Not open for further replies.

christerhaard

Programmer
Oct 5, 2002
28
0
0
SE
Hi Guys,

I have a database that has all its info linked to it from other databases (except the ID ofc). Now I would like to control what is written to it.

Example:

first_name field is "gus" second_name field is "swansson"

ok this is saved to the table

Now I dont want my user to be able to input a new entry with the same info.

But it's ok to enter:

first_name field is "gus" second_name field is "smith"

So it's the combination of two inputs that I would like to control. And I would like to do it on the lowest possible level. Probably I will have to do it in the quary for the form if there is'nt some way to do it on the table level.

Please Help. . .

MERRY X MAS and thanks in advance for the help. . .
 
Hi Christerhaard,

You can set both of those fields as primary keys and by doing that it'll do exactly as what you stated. It'll allow an unlimited first name as "gus" as long as the second field is different from the others. The same will apply backwards i.e. unlimited similar 2nd name and different first name.

in table design view, high light both keys and then right click and select primary key.

I hope I answered your questions.

Regards and Happy New Years.

Ken
 
Thanx for your input Ken!

Helps me a little. . .

Problem is that I would like to set conditions for more info in other fields too. I didn´t describe that in my first entry, sorry. . . But I would like to set conditions fore one more field lets say that "Gus" can have different lastnames but only one entry in the database can have the same phonenumber (im not building a name & address database, I´m building a race entry system) So now I will try to explain what I´m trying to do.

The system is for dragracing drivers that via web is to enter that they will participate in a certain race at a certain date. But there are a limited number of pit boxes in the pit area. so there are a few conditions I would like to make.

A driver is only to enter that he is coming one time to a certain race (no double entrys on the same race) But he can book him self on many different races.

once a pitbox has been taken on a certain race date no one else is to be able to book it.

Thanx for your help and a happy new year to all. . .

 
Hi!

Initially I'd say that this challenge would need the usage of unbound forms (forms/controls not bound to a recordsource) and that you'd have to do this "manually" -> create routines that checked all this prior to updating/appending to the tables...

But - dragracing is a sport with a rather limited number of contestants, there are actually not many drivers attending races, to be frank. So - as an idea, why don't you get the names, and other necessary information from your "local/national" ASN, load them into a "driver" database, link it to your current database and - voila?

(if the ASN does not provide such, just search the net, ALL races worth mentioning provide result service on the net, you'll find most of them there;-) - there you would also probably find drivers not belonging to your county/country/region, that might choose to participate in a race at your track)

- on the last thingie, I have some limited experience. I have three business areas, one of them being timekeeping and results post processing in national (and european) motorsport

-> use the licence number if available... much more reliable than the user typing their names (experience!;-))

On the pit box thingie - in my country, and the races I attend, such is often decided upon after the time of last entry, because there's never enough contestants. This is always done manually (often a decision of the members of the race committee/jury) Where number of contestants might exceed the number of pit boxec, I'd disallow new entries when the max entries is reached.

HTH Roy-Vidar
 
From your initial post, first and last name needs to be unique. From your second reply, it seems phone number is unique, would that suffice as primary key? Or would it have to be all three, or even more fields?

If you can't use a primary key constallation, and you don't have the possibility to verify entrants with a list of "valid" entrants, there would seem to leave only the before update event of the form.

There you could probably open a recordset using for instance first and last name as criteria, or perhaps only last name. If this recordset contains records, then check the other fields in the the recordset against controls on your form. Should you find a match, use cancel=true and give the user a message.

The challenge is the spelling, which is why I suggested having the names alredy in the database, which would make it a bit simpler using for instance combos, and select entrants to the event. In this case, a little typo would mean the same entrant can be registrated several times.

Roy-Vidar
 
Hi again,

Thanx Roy! I will try what U sugest. I did not think that it was possible to set these conditions at the table level.

You are absolutly correct about the spelling but every driver has a licens number so this will be used to make sure there are no double booking.

And yes it is correct that I probably will have more then two fields that has to be correct in a special way before im satisfied with the entry system.

Thanx / Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top