Update table from form button (1 Viewer)

N

northernMONKEY

Guest
Hi

I've got (hopefully) a small program regarding adding data to tables from a form with a button on it.

The form records details about the purchase of an animal which has a unique eartag number. When the button on the form is pressed, 3 queries are run which insert the data into the relevant tables. an example of one of the queries is shown below:

INSERT INTO CATTLE ( Eartag_num, Name, DOB, Sex, Type, [Sire Eartag], [Dam Eartag] )
SELECT [Forms]![RECORD PURCHASE]![Eartag_num], [Forms]![RECORD PURCHASE]![Name], [Forms]![RECORD PURCHASE]![DOB], [Forms]![RECORD PURCHASE]![Sex], [Forms]![RECORD PURCHASE]![Type], [Forms]![RECORD PURCHASE]![Sire Eartag], [Forms]![RECORD PURCHASE]![Dam Eartag]
FROM CATTLE
WHERE [Forms]![RECORD PURCHASE]![Eartag_num] <> CATTLE.Eartag_num;


This checks that the record is not currently in the cattle table, by comparing eartag numbers, and if it is isn't, adds it. However is there a way of bringing up a message box using VB code to let the user know that no records have been updated because the eartag number is not unique if this is the case?

Any help would be much appreciated.
Chris
 

DES

Technoweenie
Local time
Today, 08:32
Joined
Apr 17, 2001
Messages
245
Can I get the credits for doing your homework? ;-)

From what you are saying there should already be a built in option for this. it is the docmd.setwarnings. This should already be telling you if records were added and thus by default if no message no records where added. However, if you want I can look at it for you - just sent a sample off to me in 97 and I'll get it back to you.
 
N

northernMONKEY

Guest
My coursework??? Of course it isn't ;-)

The sample's in the post now. I've got the docmd.setwarnings set to true but as the database is going to be designed for a novice user we would like our own custom message boxes.
 

Users who are viewing this thread

Top Bottom