HELP! Default value dependant on another field

O

Obeide115654

Hi I would like to set up a default value in one field [ILRVAL] based on
whether a previous field [40ILR] - a yes/no field - is a yes.

Any help gratefully received.
 
M

Maurice

You could try something like:

if me.[40ILR]=-1 then
me.[ILRVAL].defaultvalue="yourvalue here"
end if

hth
 
O

Obeide115654

At the risk of sounding completely stupid... Where do I type that?
Thanks.

Maurice said:
You could try something like:

if me.[40ILR]=-1 then
me.[ILRVAL].defaultvalue="yourvalue here"
end if

hth
--
Maurice Ausum


Obeide115654 said:
Hi I would like to set up a default value in one field [ILRVAL] based on
whether a previous field [40ILR] - a yes/no field - is a yes.

Any help gratefully received.
 
M

Maurice

First of all your not stupid I'm the one who should have asked the proper info.
I assume you are talking about a form where you want this to happen?

Second: I assume you want this to happen or ceck when you enter a new
record or must the action trigger when you've entered the value in the
previous field?

In the latter: a default value will only appear when you enter a new record.
You can supply a value for the next control though. Click on the control in
the form (designview). Now choose [event tab] and click on the three little
dots beside after update. You will enter the VBE and you'll see a sub
something like:

Private sub controlname_AfterUpdate()
if me.[40ILR]=-1 then
me.[ILRVAL].defaultvalue="yourvalue here"
end if
end sub

Let me know if this helps. If not tell me how you question is set up (are
you using a form, when do you want the trigger to fire -> new record, after
specific action).
--
Maurice Ausum


Obeide115654 said:
At the risk of sounding completely stupid... Where do I type that?
Thanks.

Maurice said:
You could try something like:

if me.[40ILR]=-1 then
me.[ILRVAL].defaultvalue="yourvalue here"
end if

hth
--
Maurice Ausum


Obeide115654 said:
Hi I would like to set up a default value in one field [ILRVAL] based on
whether a previous field [40ILR] - a yes/no field - is a yes.

Any help gratefully received.
 
O

Obeide115654

Hi Maurice, Thank you for your reply and breaking everything down for me.

I have tried as you suggested, but I get the 'run time error 438 Object
doesn't support this property or method'

I was trying to set it up in the design view of the table. I don't need to
see the [ILRVAL] box, but i would like the information to be there so I can
run a report off.

I want the action to happen when the 'yes/no' box [40ILR] is ticked in the
form view (I know i'll have to come out of the record in order for it to
update) I have about a half dozen of similarly set up fields where i would
like the figure to update after ticking a yes/no box.

thanks again for your help,
Rosi



Maurice said:
You could try something like:

if me.[40ILR]=-1 then
me.[ILRVAL].defaultvalue="yourvalue here"
end if

hth
--
Maurice Ausum


Obeide115654 said:
Hi I would like to set up a default value in one field [ILRVAL] based on
whether a previous field [40ILR] - a yes/no field - is a yes.

Any help gratefully received.
 
M

Maurice

Rosi,

I see you want the value entered when you tick the box. First off you can't
do this in table design you have to put the code behind the form.

When placed behind the form you also don't need the default value you can
just assign what you would like in your field.

So:

I assume the tickbox is a Yes/No field in your table

You place the code within the OnEnter action

Private sub chk_Enter()
if me.40ILR = true then
me.irlval="type the value that you want here"
end if
End sub

I think that should do it...
--
Maurice Ausum


Obeide115654 said:
Hi Maurice, Thank you for your reply and breaking everything down for me.

I have tried as you suggested, but I get the 'run time error 438 Object
doesn't support this property or method'

I was trying to set it up in the design view of the table. I don't need to
see the [ILRVAL] box, but i would like the information to be there so I can
run a report off.

I want the action to happen when the 'yes/no' box [40ILR] is ticked in the
form view (I know i'll have to come out of the record in order for it to
update) I have about a half dozen of similarly set up fields where i would
like the figure to update after ticking a yes/no box.

thanks again for your help,
Rosi



Maurice said:
You could try something like:

if me.[40ILR]=-1 then
me.[ILRVAL].defaultvalue="yourvalue here"
end if

hth
--
Maurice Ausum


Obeide115654 said:
Hi I would like to set up a default value in one field [ILRVAL] based on
whether a previous field [40ILR] - a yes/no field - is a yes.

Any help gratefully received.
 
O

Obeide115654

WOOHOO! We have lift off! Thank you so much for all your help.
Rosi

Maurice said:
Rosi,

I see you want the value entered when you tick the box. First off you can't
do this in table design you have to put the code behind the form.

When placed behind the form you also don't need the default value you can
just assign what you would like in your field.

So:

I assume the tickbox is a Yes/No field in your table

You place the code within the OnEnter action

Private sub chk_Enter()
if me.40ILR = true then
me.irlval="type the value that you want here"
end if
End sub

I think that should do it...
--
Maurice Ausum


Obeide115654 said:
Hi Maurice, Thank you for your reply and breaking everything down for me.

I have tried as you suggested, but I get the 'run time error 438 Object
doesn't support this property or method'

I was trying to set it up in the design view of the table. I don't need to
see the [ILRVAL] box, but i would like the information to be there so I can
run a report off.

I want the action to happen when the 'yes/no' box [40ILR] is ticked in the
form view (I know i'll have to come out of the record in order for it to
update) I have about a half dozen of similarly set up fields where i would
like the figure to update after ticking a yes/no box.

thanks again for your help,
Rosi



Maurice said:
You could try something like:

if me.[40ILR]=-1 then
me.[ILRVAL].defaultvalue="yourvalue here"
end if

hth
--
Maurice Ausum


:

Hi I would like to set up a default value in one field [ILRVAL] based on
whether a previous field [40ILR] - a yes/no field - is a yes.

Any help gratefully received.
 
G

GABRIELA FREDES

hello my name is gabriela, my from is argentina,
"Obeide115654" <[email protected]> escribió en el
mensaje de noticias
WOOHOO! We have lift off! Thank you so much for all your help.
Rosi

Maurice said:
Rosi,

I see you want the value entered when you tick the box. First off you
can't
do this in table design you have to put the code behind the form.

When placed behind the form you also don't need the default value you can
just assign what you would like in your field.

So:

I assume the tickbox is a Yes/No field in your table

You place the code within the OnEnter action

Private sub chk_Enter()
if me.40ILR = true then
me.irlval="type the value that you want here"
end if
End sub

I think that should do it...
--
Maurice Ausum


Obeide115654 said:
Hi Maurice, Thank you for your reply and breaking everything down for
me.

I have tried as you suggested, but I get the 'run time error 438 Object
doesn't support this property or method'

I was trying to set it up in the design view of the table. I don't
need to
see the [ILRVAL] box, but i would like the information to be there so I
can
run a report off.

I want the action to happen when the 'yes/no' box [40ILR] is ticked in
the
form view (I know i'll have to come out of the record in order for it
to
update) I have about a half dozen of similarly set up fields where i
would
like the figure to update after ticking a yes/no box.

thanks again for your help,
Rosi



:

You could try something like:

if me.[40ILR]=-1 then
me.[ILRVAL].defaultvalue="yourvalue here"
end if

hth
--
Maurice Ausum


:

Hi I would like to set up a default value in one field [ILRVAL]
based on
whether a previous field [40ILR] - a yes/no field - is a yes.

Any help gratefully received.
 
J

John W. Vinson

hello my name is gabriela, my from is argentina,

Gabriela, if you want a chat room this is not one. It is a technical support
newsgroup.

Si quieres charlar, este no es el lugar. Este es un grupo tecnico por la
programma Microsoft Access.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top