Help writing simpler macro?

S

studlength

Hello all,
I have created a macro that makes some fields on a form visible and
others not visible depending on the selection made from a dropdown
list. Here is a portion of the current macro:

Line 1:
Condition= [Form]![Field1]="Caps"
Action= SetValue
Item= [Field2].[Visible]
Expression= No

Line 2:
Condition= [Form]![Field1]="Caps"
Action= SetValue
Item= [Field3].[Visible]
Expression= No

Line 3:
Condition= [Form]![Field1]="Caps"
Action= SetValue
Item= [Field4].[Visible]
Expression= No

So if "Caps" is chosen in Field1, then Field2, Field3, and Field4 are
not visible.

This is working great. However, this is just a small example of the
macro. What I need is a faster way to write this thing. I would like
to be able to combine these 3 lines into 1 line, but I'm not sure if
or how it can be done. I have tried the following:

Condition= [Form]![Field1]="Caps"
Action= SetValue
Item= [Field2].[Visible] AND [Field3].[Visible] AND [Field4].[Visible]
Expression= No

I was just guessing but I thought it might work. It didn't, but I hope
you can see what I am trying to do. Is there a way to combine these 3
lines into 1 line?
 
G

Guest

For a start, you don't need the condition on each line.
Just put an ellipsis ... (three dots) in each following line

But if you want anything complex, perhaps it's time
to start with VBA? Use the macro conversion wizard:

Tools, Macro, Macro conversion wizard.

You can mix your macro's with VBA: just put a
RunCode action in your Macro. A simple VBA
function like this:

function fieldinvisible()
forms!formname!Field2.[Visible] = false
forms!formname!Field3.[Visible] = false
forms!formname!Field3.[Visible] = false
end function

(david)
 

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

Multiple records per row in a continuous form 1
Query Help! 2
Conditional Macro 2
Toggle Button 1
Macro questions 3
joining several update queries into one 4
figuring averages in Access 2
Query problem. 10

Top