PDA

View Full Version : Multiple Options Selected will Add Data in Worksheet



afzalw
01-16-2017, 07:34 PM
I am using Options in Access.

If "Option1" is selected my code adds a "Text 1" in Column 1 of the "Database" sheet otherwise leave it blank.
If "Option2" is selected my code adds a "Text 2" in Column 2 of the "Database" sheet otherwise leave it blank.

I have 10 options in total. I am trying to add another portion in this code that if Option1, Option2, or any of the ten options are true than add corresponding text in the column of the Database Worksheet.

The corresponding text for each option is always same.

Option 1 = Text 1
Option 2 = Text 2
Option 3 = Text 3
Option 4 = Text 4 and so on.

Option1, Option 8 and Option 9 is selected it will generate "Text1_Text8_Text9" in the column.
Option3, Option 4 and Option 6 is selected it will generate "Text3_Text4_Text6" in the column.




Set dbsAKHwy = CurrentDb

Set rstDatabase= _
dbsAKHwy.OpenRecordset("Database", dbOpenDynaset)


With rstDatabase
.AddNew

!Column1 = IIf(Option1.Value = -1, "Text 1", "")
!Column2= IIf(Option2.Value = -1, "Text 2", "")

.Update
.Bookmark = .LastModified
End With