By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,160 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,160 IT Pros & Developers. It's quick & easy.

Option Groups in Forms

P: 71
I've got a very basic database that is tied to a website. Part of the database tracks information about training classes. Some of the training classes have flyers that go along with them in a .pdf file format - So when the user clicks on the title of the class I want it to link to the file.

To do this I've broken the table down to two fields pertaining to the flyers; the file name, and the folder it's located in. I did this because the flyers may be located in one of 4 different folders. I've got a simple textbox to store the file name, then I'd like to have 4 option buttons that match the 4 folders that the file may be in, so the user can select where the flyer is at. The problem is that the value for option buttons has to be numeric (atleast when using the option group), and I need a string type. Is there a way to get the option buttons to hold a text value that I could then store in the 'flyerfolder' field in the table? Or would there be a way for me to use the checkbox objects, but then only allow one to actually be checked at any time?

Any help on this would be greatly appreciated. It's been a while since I've done much with Access, and I'm drawing a bit of a mental blank right now on how to handle this. Thank you.
Aug 3 '07 #1
Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,669
I've got a very basic database that is tied to a website. Part of the database tracks information about training classes. Some of the training classes have flyers that go along with them in a .pdf file format - So when the user clicks on the title of the class I want it to link to the file.

To do this I've broken the table down to two fields pertaining to the flyers; the file name, and the folder it's located in. I did this because the flyers may be located in one of 4 different folders. I've got a simple textbox to store the file name, then I'd like to have 4 option buttons that match the 4 folders that the file may be in, so the user can select where the flyer is at. The problem is that the value for option buttons has to be numeric (atleast when using the option group), and I need a string type. Is there a way to get the option buttons to hold a text value that I could then store in the 'flyerfolder' field in the table? Or would there be a way for me to use the checkbox objects, but then only allow one to actually be checked at any time?

Any help on this would be greatly appreciated. It's been a while since I've done much with Access, and I'm drawing a bit of a mental blank right now on how to handle this. Thank you.
  1. Create a Text Box on your Form named txtFolder.
  2. Set the Control Source of txtFolder to the Field containing the name of the Folders.
  3. Set the Visible Property of txtFolder to No.
  4. Create an Option Group with 4 Option Buttons and name it optFolders.
  5. Do not set a Default Value for this Option Group.
  6. Make sure this option Group is Unbound (no Control Source).
  7. The Labels for each Option within the Goup should briefly describe the 4 Folder locations.
  8. In the AfterUpdate() Event of the Option Group, place similar code. Make you own substitutions where necessary.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub optFolders_AfterUpdate()
    2. Select Case Me!optFolders.Value
    3.   Case 1
    4.     Me![txtFolder] = "C:\MyFolder\Sub-Folder 1\"
    5.   Case 2
    6.     Me![txtFolder] = "C:\Program Files\Finance\Data\"
    7.   Case 3
    8.     Me![txtFolder] = "C:\Miscellaneous\"
    9.   Case 4
    10.     Me![txtFolder] = "C:\Folder 1\General Files"
    11.   Case 5
    12.     Me![txtFolder] = vbNullString    'if you want a 'None' Option.
    13. End Select
    14. End Sub
  9. After an Option is chosen, the appropriate Folder Location is written to txtFolder which is Bound to the underlying Folder Field. Once a Record is saved, the Folder Location is written to the Table along with the other relevant Data.
  10. You may want to put a 5th Option named 'None' because if you inadvertantly click on a Folder option (1 to 4), there is no way to remove it from txtFolder since it is invisible.
  11. This entire process is transparent to the User.
  12. Let me know how you make out.
Aug 4 '07 #2

P: 71
  1. Create a Text Box on your Form named txtFolder.
  2. Set the Control Source of txtFolder to the Field containing the name of the Folders.
  3. Set the Visible Property of txtFolder to No.
  4. Create an Option Group with 4 Option Buttons and name it optFolders.
  5. Do not set a Default Value for this Option Group.
  6. Make sure this option Group is Unbound (no Control Source).
  7. The Labels for each Option within the Goup should briefly describe the 4 Folder locations.
  8. In the AfterUpdate() Event of the Option Group, place similar code. Make you own substitutions where necessary.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub optFolders_AfterUpdate()
    2. Select Case Me!optFolders.Value
    3.   Case 1
    4.     Me![txtFolder] = "C:\MyFolder\Sub-Folder 1\"
    5.   Case 2
    6.     Me![txtFolder] = "C:\Program Files\Finance\Data\"
    7.   Case 3
    8.     Me![txtFolder] = "C:\Miscellaneous\"
    9.   Case 4
    10.     Me![txtFolder] = "C:\Folder 1\General Files"
    11.   Case 5
    12.     Me![txtFolder] = vbNullString    'if you want a 'None' Option.
    13. End Select
    14. End Sub
  9. After an Option is chosen, the appropriate Folder Location is written to txtFolder which is Bound to the underlying Folder Field. Once a Record is saved, the Folder Location is written to the Table along with the other relevant Data.
  10. You may want to put a 5th Option named 'None' because if you inadvertantly click on a Folder option (1 to 4), there is no way to remove it from txtFolder since it is invisible.
  11. This entire process is transparent to the User.
  12. Let me know how you make out.
Thank you very much, that should get the job done!
Aug 6 '07 #3

ADezii
Expert 5K+
P: 8,669
Thank you very much, that should get the job done!
You are quite welcome.
Aug 6 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.