Toggle data entry form field visibility by check box

I tried to search on this, it seems like it would be a fairly common thing to do, but I couldn’t find anything.

In a data entry form, I have two fields that I want to be invisible by default, unless a check box is marked, in which case they will become visible and data can be entered into them. I know how to make them invisible in the Control properties dialog, I just don’t know what to do next. I presume some sort of coding/macro is required, so I am coming to the well again. I think this will be the last time for this particular form.

A checkbox can not change anything, this has to be done by a macro, wich can be called on change/on selection of the field.

Maybe check the linked thread: The macro there does not render the items invisible, but disables them - wich I think is the better option.

Only a little bit changed. Might be it works as you want.
I have set such a function to show content depending of an entry in a listbox.

SUB Show(oEvent AS OBJECT)
   oField = oEvent.Source.Model
   oForm = oField.Parent
   oField1 = oForm.getByName("txtA")
   oField2 = oForm.getByName("txtB")
   IF oField.State = 1 THEN
      oField1.EnableVisible = True
      oField2.EnableVisible = True
   ELSE
      oField1.EnableVisible = False
      oField2.EnableVisible = False
   END IF
END SUB

I need help adding a second macro. When I click Tools - Macros - Organize Macros - Basic, and click on the database file and click New, I don’t get a new screen, I get the first macro (that you helped me with yesterday). Am I adding a second macro to the first Module, or am I adding a new Module?

Also, I managed somehow to mess up the first macro, and now I am getting a runtime error. Can I ask about that in this thread, or should I go back to the other thread?

You only need to organize macros if you create the first modul.

Now: Choose Tools → Macros → Edit Macros
Then choose your database file.
There is a default folder, which contains “Module1”.
Click on “Module1”.
Your old macro is there.
Now copy the new macro code.
Set the cursor at the end of the previous macro code and type Enter for a new line.
Insert new macro code.

Now you could use both macros, which are in “Module1”.

If there are problems: Post a screenshot of “Module1” with both procedures (“macros”).

Thank you for the instructions on adding a macro. Here is the printscreen of Module1. In the “Copy” macro I decided to reduce it to 2 fields. The runtime error is on oField = oEvent.Source.Model (in both pieces of code) and it says “Argument is not optional.” I don’t know how to step through the code to see if there are any other problems. This was working before, I messed it up and had to copy it back in when I first tried to add another macro.

How do you start the procedures. You have written

You have to start both procedures from such a check box, which is part of the form. The procedure will read the variables for this field and the form with oEvent. If you start it in macro editor there isn’t any event, there isn’t the checkbox and there isn’t the form.