Macro using DLookup Function

P

pedro

I would like to create a macro that auto populates a check box based on a
selection from a drop down list in another field on the same form.

The field is called 'Status' and when I select 'Resolved' from a drop down
list (the list is based on a table) I would like the check box to populate
with a 'tick'.

I guess I would use the after update event in the Status field then use the
'set value' macro. I'm not sure if I should use a DLookup function as the
condition of the macro.

Any ideas on have this may look?

thanks
 
S

Steve Schapel

Pedro,

You could do it as you suggested. In that case, the Condition for the
SetValue action will simply be:
[Status]="Resolved"

However, I should also say that to have the value of one field dependent
on the value of another would normally indicate an incorrect data
design. So I really suspect that what you are doing here is faulty.
Let us know if you would like to explore this aspect.
 
P

pedro

Thanks for that.

I think I need to do the reverse - auto populate the status field if the
check box is clicked - ie when check box is 'ticked' status becomes 'Resolved'

I have tried to create this macro using the 'on click' event for the check
box and using a 'setvalue' macro where the condition is set to [checkbox] =
yes.

However I am not sure what to enter for the Item and Expression fields for
the macro. I have set the expression to where status = 'Resolved' however
when I test the macro and click the check box the status field changes to 0
or -1 (reflecting the values of the check box.

any ideas?

thanks.
 
P

pedro

Thanks for that.

I think I need to do the reverse - auto populate the status field if the
check box is clicked - ie when check box is 'ticked' status becomes 'Resolved'

I have tried to create this macro using the 'on click' event for the check
box and using a 'setvalue' macro where the condition is set to [checkbox] =
yes.

However I am not sure what to enter for the Item and Expression fields for
the macro. I have set the expression to where status = 'Resolved' however
when I test the macro and click the check box the status field changes to 0
or -1 (reflecting the values of the check box.

any ideas?

thanks.



Steve Schapel said:
Pedro,

You could do it as you suggested. In that case, the Condition for the
SetValue action will simply be:
[Status]="Resolved"

However, I should also say that to have the value of one field dependent
on the value of another would normally indicate an incorrect data
design. So I really suspect that what you are doing here is faulty.
Let us know if you would like to explore this aspect.

--
Steve Schapel, Microsoft Access MVP
I would like to create a macro that auto populates a check box based on a
selection from a drop down list in another field on the same form.

The field is called 'Status' and when I select 'Resolved' from a drop down
list (the list is based on a table) I would like the check box to populate
with a 'tick'.

I guess I would use the after update event in the Status field then use the
'set value' macro. I'm not sure if I should use a DLookup function as the
condition of the macro.

Any ideas on have this may look?

thanks
 
S

Steve Schapel

Pedro,

I can now confirm my previous concerns... What you are doing here is
incorrect practice in a database.

With that proviso (i.e. proceed at your own risk!), the Arguments of the
SetValue macro action would be..

Condition: [checkbox]<>0
Item: [Status]
Expression: "Resolved"

This macro would go on the checkbox's After Update event.
 

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

Similar Threads


Top