This is probably an easy question for more experienced users:
I need to use a Push Button in a Form to trigger a procedure similar to the “Select Same” function in the Data Sheet. When button is pushed, it needs to select all records in the same Database where a given text field “X” matches that of the active record. I’m using the button because I don’t want the fields to appear on the Form itself. Can someone please give me a hint regarding how to code this procedure?
You can put Dave’s code directly into the “Code” part of the button’s properties, but the better way is to put it into a new procedure (e.g. named “Select Same”) and to put this line into the the Code property of the button:
I’m going to quibble with the characterization of this method as “better” in this particular case. It’s only two lines of code, and probably won’t be reused anywhere else. Personally, I would usually put this code right into the button.
When the code starts getting longer, or if the same code needs to be used from multiple buttons and/or menu items, then I definitely agree that putting the code in a separate named procedure is better.