Form with automatic field values

P

Pedro

Hello everyone
I have the main form called Table Dados where i enter all data i need and
one of the field, VALUEPREP, it's suppose to do this :
If [Comis] is FALSE
then 0
ELSE
(IF [VALVEND] IS Between 0 and 30)
Then 5€
(IF [VALVEND] IS Between 31 and 50)
Then 10€
(IF [VALVEND] IS Between 51 and 90)
Then 15€
and so on ... (is it better to have a table for this numbers 30, 50, 90
etc?)
ENDIF

I don't understand much of access so please try to explain me like i'm 10
years old pls.
Any help it's very apreciated
Tks in advance
Pedro
 
K

Klatuu

Where are you trying to use this code? It looks like a mixture of VBA and
SQL, but not exacly either.
If you can tell me what you are doing, I can help get it to work for you.
 
P

Pedro

Hi Klatuu
I guess that's a mix of what you've said, but it's what i would like to, in
theory, one of the fields to do, VALUEPREP. This field, before anything,
gotta check if a field called [Comis] is true or false. In case it's false,
value 0, but if not, have to check another field, [Valvend], and there are
only 5 or 6 possibilities (Between 0 and 30, between 31 and 50 ...) . If
first, then 5, if 2nd, then 10 and so on.
Hope i was clear enough for you. Please help me but don't forget to do it
like i'm 10 years old.
Tks in advance
Pedro

Klatuu said:
Where are you trying to use this code? It looks like a mixture of VBA and
SQL, but not exacly either.
If you can tell me what you are doing, I can help get it to work for you.
--
Dave Hargis, Microsoft Access MVP


Pedro said:
Hello everyone
I have the main form called Table Dados where i enter all data i need and
one of the field, VALUEPREP, it's suppose to do this :
If [Comis] is FALSE
then 0
ELSE
(IF [VALVEND] IS Between 0 and 30)
Then 5€
(IF [VALVEND] IS Between 31 and 50)
Then 10€
(IF [VALVEND] IS Between 51 and 90)
Then 15€
and so on ... (is it better to have a table for this numbers 30, 50, 90
etc?)
ENDIF

I don't understand much of access so please try to explain me like i'm 10
years old pls.
Any help it's very apreciated
Tks in advance
Pedro
 
K

Klatuu

I understand, but where will this code be? In a procedure (sub or function),
an SQL query?
When you say "field", do you mean a field in a recordset/table, or controls
on a form?
--
Dave Hargis, Microsoft Access MVP


Pedro said:
Hi Klatuu
I guess that's a mix of what you've said, but it's what i would like to, in
theory, one of the fields to do, VALUEPREP. This field, before anything,
gotta check if a field called [Comis] is true or false. In case it's false,
value 0, but if not, have to check another field, [Valvend], and there are
only 5 or 6 possibilities (Between 0 and 30, between 31 and 50 ...) . If
first, then 5, if 2nd, then 10 and so on.
Hope i was clear enough for you. Please help me but don't forget to do it
like i'm 10 years old.
Tks in advance
Pedro

Klatuu said:
Where are you trying to use this code? It looks like a mixture of VBA and
SQL, but not exacly either.
If you can tell me what you are doing, I can help get it to work for you.
--
Dave Hargis, Microsoft Access MVP


Pedro said:
Hello everyone
I have the main form called Table Dados where i enter all data i need and
one of the field, VALUEPREP, it's suppose to do this :
If [Comis] is FALSE
then 0
ELSE
(IF [VALVEND] IS Between 0 and 30)
Then 5€
(IF [VALVEND] IS Between 31 and 50)
Then 10€
(IF [VALVEND] IS Between 51 and 90)
Then 15€
and so on ... (is it better to have a table for this numbers 30, 50, 90
etc?)
ENDIF

I don't understand much of access so please try to explain me like i'm 10
years old pls.
Any help it's very apreciated
Tks in advance
Pedro
 
P

Pedro

Sorry for the delay ... i meant for a field on a form

Klatuu said:
I understand, but where will this code be? In a procedure (sub or function),
an SQL query?
When you say "field", do you mean a field in a recordset/table, or controls
on a form?
--
Dave Hargis, Microsoft Access MVP


Pedro said:
Hi Klatuu
I guess that's a mix of what you've said, but it's what i would like to, in
theory, one of the fields to do, VALUEPREP. This field, before anything,
gotta check if a field called [Comis] is true or false. In case it's false,
value 0, but if not, have to check another field, [Valvend], and there are
only 5 or 6 possibilities (Between 0 and 30, between 31 and 50 ...) . If
first, then 5, if 2nd, then 10 and so on.
Hope i was clear enough for you. Please help me but don't forget to do it
like i'm 10 years old.
Tks in advance
Pedro

Klatuu said:
Where are you trying to use this code? It looks like a mixture of VBA and
SQL, but not exacly either.
If you can tell me what you are doing, I can help get it to work for you.
--
Dave Hargis, Microsoft Access MVP


:

Hello everyone
I have the main form called Table Dados where i enter all data i need and
one of the field, VALUEPREP, it's suppose to do this :
If [Comis] is FALSE
then 0
ELSE
(IF [VALVEND] IS Between 0 and 30)
Then 5€
(IF [VALVEND] IS Between 31 and 50)
Then 10€
(IF [VALVEND] IS Between 51 and 90)
Then 15€
and so on ... (is it better to have a table for this numbers 30, 50, 90
etc?)
ENDIF

I don't understand much of access so please try to explain me like i'm 10
years old pls.
Any help it's very apreciated
Tks in advance
Pedro
 
K

Klatuu

Well, Pedro, terminology is a bit mixed here. Although you will see it
incorrectly used even by Microsoft, forms do not have fields, they have
controls. Fields are properties of tables or queries.

In any case, the best way to do this is with a Select Case statment.

If Not Me.Comis Then
Me.VALUEPREP = 0
ELSE
Select Case Me.VALVEND
Case 0 to 30
Me.VALUEPREP = 5€
Case 31 to 50
Me.VALUEPREP = 10€
Case 51 to 90
Me.VALUEPREP = 15€
'And So On
Case Else
MsgBox "No Valid Number"
End Select
ENDIF

Where the code will go I can't tell you because you did not provide enough
information.

--
Dave Hargis, Microsoft Access MVP


Pedro said:
Sorry for the delay ... i meant for a field on a form

Klatuu said:
I understand, but where will this code be? In a procedure (sub or function),
an SQL query?
When you say "field", do you mean a field in a recordset/table, or controls
on a form?
--
Dave Hargis, Microsoft Access MVP


Pedro said:
Hi Klatuu
I guess that's a mix of what you've said, but it's what i would like to, in
theory, one of the fields to do, VALUEPREP. This field, before anything,
gotta check if a field called [Comis] is true or false. In case it's false,
value 0, but if not, have to check another field, [Valvend], and there are
only 5 or 6 possibilities (Between 0 and 30, between 31 and 50 ...) . If
first, then 5, if 2nd, then 10 and so on.
Hope i was clear enough for you. Please help me but don't forget to do it
like i'm 10 years old.
Tks in advance
Pedro

:

Where are you trying to use this code? It looks like a mixture of VBA and
SQL, but not exacly either.
If you can tell me what you are doing, I can help get it to work for you.
--
Dave Hargis, Microsoft Access MVP


:

Hello everyone
I have the main form called Table Dados where i enter all data i need and
one of the field, VALUEPREP, it's suppose to do this :
If [Comis] is FALSE
then 0
ELSE
(IF [VALVEND] IS Between 0 and 30)
Then 5€
(IF [VALVEND] IS Between 31 and 50)
Then 10€
(IF [VALVEND] IS Between 51 and 90)
Then 15€
and so on ... (is it better to have a table for this numbers 30, 50, 90
etc?)
ENDIF

I don't understand much of access so please try to explain me like i'm 10
years old pls.
Any help it's very apreciated
Tks in advance
Pedro
 
Top