Sometimes calculate a field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all..

I have a yes/no box on my form and when it is 'ticked' I want it to do a
calculation.
If it is not 'ticked' I want the value "0" to show.

this is the code i'm using..
-------------------
Private Sub Verwarmingstoeslag_GotFocus()
If Me![ja/nee verwarmingstoeslag] = False Then
[Verwarmingstoeslag] = "0"
Else:
[Verwarmingstoeslag] = [Standaard_waarden]![Verwarmingstoeslag_waarde] *
Me![Aantal_nachten]
End If
End sub
-----------------------

the first 'if' part works fine , however the second 'else' part gives me an
error..
Does anybody has any idea?

fyi..

[Standaard_waarden] = a table
[Verwarmingstoeslag_waarde] = a standard value which is defind in the
'Standaard waarden' table..

thnx!!

Arjan
 
You can't refer to values in tables like that.

If there's only the one row in table Standaard_waarden, try

[Verwarmingstoeslag] = DLookup("Verwarmingstoeslag_waarde",
"Standaard_waarden") * Me![Aantal_nachten]
 
Hi Doug,

I used your code, however I get errormessage 3075.
(operator missing)

any idea?

Arjan

Douglas J. Steele said:
You can't refer to values in tables like that.

If there's only the one row in table Standaard_waarden, try

[Verwarmingstoeslag] = DLookup("Verwarmingstoeslag_waarde",
"Standaard_waarden") * Me![Aantal_nachten]


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Arjan said:
Hi all..

I have a yes/no box on my form and when it is 'ticked' I want it to do a
calculation.
If it is not 'ticked' I want the value "0" to show.

this is the code i'm using..
-------------------
Private Sub Verwarmingstoeslag_GotFocus()
If Me![ja/nee verwarmingstoeslag] = False Then
[Verwarmingstoeslag] = "0"
Else:
[Verwarmingstoeslag] = [Standaard_waarden]![Verwarmingstoeslag_waarde] *
Me![Aantal_nachten]
End If
End sub
-----------------------

the first 'if' part works fine , however the second 'else' part gives me
an
error..
Does anybody has any idea?

fyi..

[Standaard_waarden] = a table
[Verwarmingstoeslag_waarde] = a standard value which is defind in the
'Standaard waarden' table..

thnx!!

Arjan
 
Did you type that all on one line, or did you get confused by the line-wrap
introduced by the newsreader?

Is there only one row in table Standaard_waarden?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Arjan said:
Hi Doug,

I used your code, however I get errormessage 3075.
(operator missing)

any idea?

Arjan

Douglas J. Steele said:
You can't refer to values in tables like that.

If there's only the one row in table Standaard_waarden, try

[Verwarmingstoeslag] = DLookup("Verwarmingstoeslag_waarde",
"Standaard_waarden") * Me![Aantal_nachten]


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Arjan said:
Hi all..

I have a yes/no box on my form and when it is 'ticked' I want it to do
a
calculation.
If it is not 'ticked' I want the value "0" to show.

this is the code i'm using..
-------------------
Private Sub Verwarmingstoeslag_GotFocus()
If Me![ja/nee verwarmingstoeslag] = False Then
[Verwarmingstoeslag] = "0"
Else:
[Verwarmingstoeslag] = [Standaard_waarden]![Verwarmingstoeslag_waarde]
*
Me![Aantal_nachten]
End If
End sub
-----------------------

the first 'if' part works fine , however the second 'else' part gives
me
an
error..
Does anybody has any idea?

fyi..

[Standaard_waarden] = a table
[Verwarmingstoeslag_waarde] = a standard value which is defind in the
'Standaard waarden' table..

thnx!!

Arjan
 
Sory Douglas, my mistake, I mispelled the table name... ;P
thans for your help!


Arjan

Douglas J. Steele said:
Did you type that all on one line, or did you get confused by the line-wrap
introduced by the newsreader?

Is there only one row in table Standaard_waarden?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Arjan said:
Hi Doug,

I used your code, however I get errormessage 3075.
(operator missing)

any idea?

Arjan

Douglas J. Steele said:
You can't refer to values in tables like that.

If there's only the one row in table Standaard_waarden, try

[Verwarmingstoeslag] = DLookup("Verwarmingstoeslag_waarde",
"Standaard_waarden") * Me![Aantal_nachten]


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hi all..

I have a yes/no box on my form and when it is 'ticked' I want it to do
a
calculation.
If it is not 'ticked' I want the value "0" to show.

this is the code i'm using..
-------------------
Private Sub Verwarmingstoeslag_GotFocus()
If Me![ja/nee verwarmingstoeslag] = False Then
[Verwarmingstoeslag] = "0"
Else:
[Verwarmingstoeslag] = [Standaard_waarden]![Verwarmingstoeslag_waarde]
*
Me![Aantal_nachten]
End If
End sub
-----------------------

the first 'if' part works fine , however the second 'else' part gives
me
an
error..
Does anybody has any idea?

fyi..

[Standaard_waarden] = a table
[Verwarmingstoeslag_waarde] = a standard value which is defind in the
'Standaard waarden' table..

thnx!!

Arjan
 
Sorry Douglas, my mistake... I misspelled a table name... :p
Thanks for your help!!

Arjan

Douglas J. Steele said:
Did you type that all on one line, or did you get confused by the line-wrap
introduced by the newsreader?

Is there only one row in table Standaard_waarden?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Arjan said:
Hi Doug,

I used your code, however I get errormessage 3075.
(operator missing)

any idea?

Arjan

Douglas J. Steele said:
You can't refer to values in tables like that.

If there's only the one row in table Standaard_waarden, try

[Verwarmingstoeslag] = DLookup("Verwarmingstoeslag_waarde",
"Standaard_waarden") * Me![Aantal_nachten]


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hi all..

I have a yes/no box on my form and when it is 'ticked' I want it to do
a
calculation.
If it is not 'ticked' I want the value "0" to show.

this is the code i'm using..
-------------------
Private Sub Verwarmingstoeslag_GotFocus()
If Me![ja/nee verwarmingstoeslag] = False Then
[Verwarmingstoeslag] = "0"
Else:
[Verwarmingstoeslag] = [Standaard_waarden]![Verwarmingstoeslag_waarde]
*
Me![Aantal_nachten]
End If
End sub
-----------------------

the first 'if' part works fine , however the second 'else' part gives
me
an
error..
Does anybody has any idea?

fyi..

[Standaard_waarden] = a table
[Verwarmingstoeslag_waarde] = a standard value which is defind in the
'Standaard waarden' table..

thnx!!

Arjan
 
Back
Top