Richard has attended:
Access Advanced course
Forms
I have a form that displays address fields from a table. I am displaying two sets of addresses that have been cleaned. So there is the before and after address on the screen.
I want to have a button on the form that if pressed will enter the word Yes in a specific field. The field that is to be used is a new field and does not have any data in it.
How do I create this button?
Thanks
RE: Forms
Good question.
First Create a Macro
- Use the SetValue command.
- In ITEM , specify the name of the field you want to set
- In EXPRESSION, enter "Yes" (including inverted commas)
Save and then give the macro a name.
Now go to the form in Design view
- Add a command button using the Toolbox
- Cancel the Wizard that starts when you draw the box
- Go to to the properties of the command box
- Select the EVENT tab, and then choose the ONCLICK box
- Drop down the arrow, and select the name of the MARCO you just recorded.
SAVE
TEST the system.
Let me know how you do.
Regards
Richard
RE: Forms
Thanks for email. I have created the command button as you instructed.
When I test the button the following error messages appear. I'm not sure what they mean.
The object doesn't contain the Automation object '3b - For Review UK.' (Note: 3b - For Review Uk is the table name)
You tried to run a Visual Basic procedure to set a property or method for an object. However, the component doesn't make the property or method available for Automation operations.
Check the component's documentation for information on the properties and methods it makes available for Automation operations.
(Note: When you press OK to this message, the following message appears:)
Action Failed
Macro Name: Update record with Yes
Condition: True
Action Name: SetValue
Arguments: [3b - For Review UK]![Update], "Yes"
(Note: There are three buttons on this screen but only one is usable, the other two are grayed out. The usuable button is called Halt, the two grayed out buttons are called Step and Continue.
Any ideas how I can fix this problem. I have also created a second command button in the same way that updates the same field with the value "No". The same two error messages appear, except the second error message has the macro name and argument of:
Macro Name: Update record with No
Arguments: [3b - For Review UK]![Update], "No"
Many Thanks
RE: Forms
Hi Richard,
Just to let you know that I have fixed the error that I was getting. The reason I was getting an error was that in the item line on the macro I chose the field that is to be updated by drilling down in the tables and finding the field.
I changed this by adding the field that is to be updated into the form but made that field invisable so that it does not appear on the form.
I then went back to the macro and in the item line, I drilled down in the forms, and found the newly added field.
This now adds the value Yes to the field.
I have also added another command button that adds the value No when pressed.
Thank you for your help. Much appreciated.
Richard
RE: Forms
A pleasure, glad you got it working