Use Visual Basic to modify form properties
1. Start Access and open the database we created in the last tute, select the 'Forms' tab and select the 'Baseline Form' then hit the 'Design' button. If you did not compete the last tute you can download the database click here to download.
2. Select the first option group 'Frame15' and look at the properties of that object, select the 'Event' tab choose the 'On Click' property and hit the build button.
3. Type in the follow code, this reads if the Q1 object on the form = 1 then switch off the Q2 & Q3 objects (make them invisible) else make them visible.
4. Try the form with the new code.
5. When Q1=1 then Q2 & Q3 are set to invisible mode. This code could be extended such that you don't see any questions until the previous question has been answered, close the form.
6. This is the single most important piece of code you will ever use in Access, Dim MyDB As Database, MyREC As Recordset, criteria1 As StringSet MyDB = DBEngine.Workspaces(0).Databases(0)Set MyREC = MyDB.OpenRecordset("Participants", DB_OPEN_DYNASET)criteria1 = "FirstName = 'myle'"MyREC.FindFirst criteria1MyREC.EditMyREC!Title = "datatest"MyREC.Update
Go to the modules tab and press the new key to create a new module.
7. Create a new function called 'DataTest'.
8. Save the module as 'TestModule'
9. Copy the above code into the new function. 10. Table before code runs.
11. Table after code runs. Copyright © 1999 R&D Robotics Pty Ltd, All rights reserved. Any copyright subsisting in the above code and or literary works including source files vests with R&D Robotics Pty Ltd. ACN 086 345 137
2. Select the first option group 'Frame15' and look at the properties of that object, select the 'Event' tab choose the 'On Click' property and hit the build button.
3. Type in the follow code, this reads if the Q1 object on the form = 1 then switch off the Q2 & Q3 objects (make them invisible) else make them visible.
4. Try the form with the new code.
5. When Q1=1 then Q2 & Q3 are set to invisible mode. This code could be extended such that you don't see any questions until the previous question has been answered, close the form.
6. This is the single most important piece of code you will ever use in Access, Dim MyDB As Database, MyREC As Recordset, criteria1 As StringSet MyDB = DBEngine.Workspaces(0).Databases(0)Set MyREC = MyDB.OpenRecordset("Participants", DB_OPEN_DYNASET)criteria1 = "FirstName = 'myle'"MyREC.FindFirst criteria1MyREC.EditMyREC!Title = "datatest"MyREC.Update
Go to the modules tab and press the new key to create a new module.
7. Create a new function called 'DataTest'.
8. Save the module as 'TestModule'
9. Copy the above code into the new function. 10. Table before code runs.
11. Table after code runs. Copyright © 1999 R&D Robotics Pty Ltd, All rights reserved. Any copyright subsisting in the above code and or literary works including source files vests with R&D Robotics Pty Ltd. ACN 086 345 137