HELP!!! Validation rule

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I have to introduce in a table some data, using a form with contrtols: combo
boxes and text boxes. The fields need to follow some VALIDATION RULES, and
to display the VALIDATION TEXT as the error message.
The validation rules must to fields from a query, because the that table is
used to extract items from a storage and it musn't contain data that was not
entered (that query representing the state of the storage at that moment).
How can I do this thing?
Please, help me! I'm stucked.
 
I have to introduce in a table some data, using a form with contrtols: combo
boxes and text boxes. The fields need to follow some VALIDATION RULES, and
to display the VALIDATION TEXT as the error message.
The validation rules must REFER to fields from a query, because the that
table is
used to extract items from a storage and it musn't contain data that was not
entered (that query representing the state of the storage at that moment).
How can I do this thing?
Please, help me! I'm stucked.
 
Hi Chris,

If you're storing your data in a Jet database (an .mdb file) you can't
do this at the table level. Instead, put your validation code in event
procedures of the form and its controls. Typically, validation for a
single field would be in the corresponding control's BeforeUpdate event,
or validation for the entire record in the form's BeforeUpdate event.
 
I must introduce the data in a table(the table of the exits from a stock)
through a form having the controls :
Textbox:DATA; cmbbox ID_material; cmbbox ID_dimensions; cmbbox
ID_Quality; Textbox Quantity, cmbbox UM (kg, m, or pieces); Texbox
UnitPrice; cmbbox MonetarUnit; CmbBox ID_order; textbox ProductCode;
Textbox UnitsOfProduct

These record must not contain data not entered. The entered data (totalized
by categories) is represented by the query:

SELECT DISTINCT [stoc1-0].Mat_Code, [stoc1-0].Material,
[stoc1-0].Dimensions, [stoc1-0].Quality, Sum([stoc1-0].[Length(m)]) AS
[SumOfLength(m)], Sum([stoc1-0].[Quantity(kg)]) AS [SumOfQuantity(kg)],
Sum([stoc1-0].[Quantity(pieces)]) AS SumOf[Quantity(pieces)],
[stoc1-0].ID_material, [stoc1-0].ID_Dimensions, [stoc1-0].Cod_Calit,
[stoc1-0].UM, [stoc1-0].UnitPrice, Sum([stoc1-0].[TotalPrice]) AS
[SumOfTotalPrice], [stoc1-0].[Price(euro)],
Sum([stoc1-0].[TotalPrice(euro)]) AS SumOf[TotalPrice(euro)]
FROM [stoc1-0]
GROUP BY [stoc1-0].Material_Code, [stoc1-0].Material, [stoc1-0].Dimensions,
[stoc1-0].Quality, [stoc1-0].ID_material, [stoc1-0].ID_Dimensions,
[stoc1-0].Cod_Calit, [stoc1-0].UM, [stoc1-0].UnitPrice,
[stoc1-0].[Price(euro)]
ORDER BY [stoc1-0].Material, [stoc1-0].Quality, [stoc1-0].Dimensions;

(Mat_code is : Format([id_material];"000") & Format([id_dimensions];"000")
& Format([ID_Quality];"000")

Can you help me ?
How can I validate in this situation the entire record in the BeforeUpdate
event? Or how can it be made for every field?
I would apreciate your help.
 
Chris,

You can create a validation rule per control on a form.
On the form, select a control and in the properties window, select the DATA tab.

If you want to validate data on a calculated field, you will need to create a procedure on the Form BeforeUpdate Event:
Let assume that the SumOfTotalPrice field must be validated:

Private Sub Form_BeforeUpdate(Cancel As Integer)

'If SumOfTotalPrice must be > 5:
If Me.SumOfTotalPrice <= 5 Then
MsgBox "SumOfTotalPrice must be greater than 5..."
'Set cancel to true so no update to the table
Cancel = True
End If


End Sub

Eric

Chris said:
I must introduce the data in a table(the table of the exits from a stock)
through a form having the controls :
Textbox:DATA; cmbbox ID_material; cmbbox ID_dimensions; cmbbox
ID_Quality; Textbox Quantity, cmbbox UM (kg, m, or pieces); Texbox
UnitPrice; cmbbox MonetarUnit; CmbBox ID_order; textbox ProductCode;
Textbox UnitsOfProduct

These record must not contain data not entered. The entered data (totalized
by categories) is represented by the query:

SELECT DISTINCT [stoc1-0].Mat_Code, [stoc1-0].Material,
[stoc1-0].Dimensions, [stoc1-0].Quality, Sum([stoc1-0].[Length(m)]) AS
[SumOfLength(m)], Sum([stoc1-0].[Quantity(kg)]) AS [SumOfQuantity(kg)],
Sum([stoc1-0].[Quantity(pieces)]) AS SumOf[Quantity(pieces)],
[stoc1-0].ID_material, [stoc1-0].ID_Dimensions, [stoc1-0].Cod_Calit,
[stoc1-0].UM, [stoc1-0].UnitPrice, Sum([stoc1-0].[TotalPrice]) AS
[SumOfTotalPrice], [stoc1-0].[Price(euro)],
Sum([stoc1-0].[TotalPrice(euro)]) AS SumOf[TotalPrice(euro)]
FROM [stoc1-0]
GROUP BY [stoc1-0].Material_Code, [stoc1-0].Material, [stoc1-0].Dimensions,
[stoc1-0].Quality, [stoc1-0].ID_material, [stoc1-0].ID_Dimensions,
[stoc1-0].Cod_Calit, [stoc1-0].UM, [stoc1-0].UnitPrice,
[stoc1-0].[Price(euro)]
ORDER BY [stoc1-0].Material, [stoc1-0].Quality, [stoc1-0].Dimensions;

(Mat_code is : Format([id_material];"000") & Format([id_dimensions];"000")
& Format([ID_Quality];"000")

Can you help me ?
How can I validate in this situation the entire record in the BeforeUpdate
event? Or how can it be made for every field?
I would apreciate your help.
 
Back
Top