Dynamic field

M

Mohammad Mobin

there are 4 fields in a table/form (3 of them are checkbox and one text) so
the question is:

How i can store a value for each time user puts a checkmark on individual
fields.

Example:
option1 (yes/no checkbox)
option2 (yes/no checkbox)
option3 (yes/no checkbox)
result (text)
when user puts a checkmark on option1 so "New York" should be stored in the
text field and when user puts checkmark on option2 so "New York, London"
should be stored in the text field. (New York as to come from option1
checkmark and London should come from option2)
When user removes checkmark from option1 so the value in text field should
be only "London".

I am looking forward for reply

Thanks
 
D

Dirk Goldgar

Mohammad Mobin said:
there are 4 fields in a table/form (3 of them are checkbox and one text)
so
the question is:

How i can store a value for each time user puts a checkmark on individual
fields.

Example:
option1 (yes/no checkbox)
option2 (yes/no checkbox)
option3 (yes/no checkbox)
result (text)
when user puts a checkmark on option1 so "New York" should be stored in
the
text field and when user puts checkmark on option2 so "New York, London"
should be stored in the text field. (New York as to come from option1
checkmark and London should come from option2)
When user removes checkmark from option1 so the value in text field should
be only "London".


From your description, it sounds like the text string you're creating is
entirely dependent on the values of the check boxes -- the text should
always correspond exactly to the boxes that are checked. If that's true,
there is no reason for the text box to exist at all. Instead, this value
should be calculated whenever it is needed; either as a calculated control
on a form or report, or as a calculated field in a query. An expression
that would do that is (for example):

Mid(IIf(Option1, ", New York", "") & IIf(Option2, ", London", "") &
IIf(Option3, ", Paris", ""), 3)

That expression will have been broken onto two lines by the newsreader, but
it would have to be entered all on one line if used as a controlsource
expression.

Note that if you use this as a controlsource expression, you must precede it
with the = sign, to let Access know it's an expression. It's probably
handiest, though, to create a query that calcuates the field, and just base
your forms or reports on that query. For example, this SQL:

SELECT
Option1, Option2, Option3,
Mid(IIf(Option1, ", New York", "") &
IIf(Option2, ", London", "") &
IIf(Option3, ", Paris", ""),
3)
AS Cities
FROM YourTable;
 

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