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
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