NeutronFlux
Registered User.
- Local time
- Today, 18:09
- Joined
- Aug 20, 2012
- Messages
- 78
Hello,
So I'm working on an Access 2007 application for my company's suppliers list, but I am restricted to using a single Excel worksheet for the back-end. One of the fields, called [Files], is a list of files in .pdf format related to a supplier. The number of files can be 0, 1 or many. I currently have this field set up so that each file is separated by a semi-colon. A sample first record in [Files] is:
K:\Users\test user\2008-12-24-ASTM D5857-08.pdf;
K:\Users\test user\2012-03-12APCPP25-Black.pdf;
K:\Users\test user\DIN_16901.pdf
The front-end contains a multi-item form. I'm trying to add a ComboBox (cboFiles) for each record, which is populated by the value in [Files]. Then, selecting an item in the ComboBox should automatically open that file.
I've tried a few approaches so far for populating the ComboBox:
Setting [Files] as the Control Source results in a single item appearing as
"K:\Users\test user\2008-12-24-ASTM D5857-08.pdf;K:\Users\test user\2012-03-12APCPP25-Black.pdf;K:\Users\test user\DIN_16901.pdf"
I also tried setting the ComboBox Record Source Type to Value List and created a hidden TextBox (txtFiles) with the Control Source set as [Files]. Then I used VBA in Form_Load to equate the ComboBox Row Source to the TextBox.
The code is simply:
While this does create a ComboBox with the correct items for the first record, it also populates the ComboBox for all the other records with the same thing, ie. every ComboBox has the items:
- K:\Users\test user\2008-12-24-ASTM D5857-08.pdf
- K:\Users\test user\2012-03-12APCPP25-Black.pdf
- K:\Users\test user\DIN_16901.pdf
I'm thinking maybe this approach could work with some modification in the code or approach. Unfortunately, I'm not too clear on why the code goes through all the Me.cboFiles.RowSource, but only once on Me.txtFiles or how to get it to check the txtFile for each row. Otherwise, I will need to figure out some other way to fill in the ComboBoxes.
Suggestions for fixes or alternative solutions will be greatly appreciated.
Edit: Actually, I've noticed something peculiar. Each time I select an item from a ComboBox, the other ComboBoxes for the other records also change to the same item. I think this has to do with cboFiles being unbound. Changing it to bound doesn't seem to be quite right though as it just gives the same default values as txtFiles while the items are still just copied from the first cboFiles. Also, I can't actually select any of the items when it's bound. I imagine it might have to do with the read-only attributes of a linked Excel File.
So I'm working on an Access 2007 application for my company's suppliers list, but I am restricted to using a single Excel worksheet for the back-end. One of the fields, called [Files], is a list of files in .pdf format related to a supplier. The number of files can be 0, 1 or many. I currently have this field set up so that each file is separated by a semi-colon. A sample first record in [Files] is:
K:\Users\test user\2008-12-24-ASTM D5857-08.pdf;
K:\Users\test user\2012-03-12APCPP25-Black.pdf;
K:\Users\test user\DIN_16901.pdf
The front-end contains a multi-item form. I'm trying to add a ComboBox (cboFiles) for each record, which is populated by the value in [Files]. Then, selecting an item in the ComboBox should automatically open that file.
I've tried a few approaches so far for populating the ComboBox:
Setting [Files] as the Control Source results in a single item appearing as
"K:\Users\test user\2008-12-24-ASTM D5857-08.pdf;K:\Users\test user\2012-03-12APCPP25-Black.pdf;K:\Users\test user\DIN_16901.pdf"
I also tried setting the ComboBox Record Source Type to Value List and created a hidden TextBox (txtFiles) with the Control Source set as [Files]. Then I used VBA in Form_Load to equate the ComboBox Row Source to the TextBox.
The code is simply:
Code:
Private Sub Form_Load()
Me.cboFiles.RowSource = Me.txtFiles
End Sub
- K:\Users\test user\2008-12-24-ASTM D5857-08.pdf
- K:\Users\test user\2012-03-12APCPP25-Black.pdf
- K:\Users\test user\DIN_16901.pdf
I'm thinking maybe this approach could work with some modification in the code or approach. Unfortunately, I'm not too clear on why the code goes through all the Me.cboFiles.RowSource, but only once on Me.txtFiles or how to get it to check the txtFile for each row. Otherwise, I will need to figure out some other way to fill in the ComboBoxes.
Suggestions for fixes or alternative solutions will be greatly appreciated.
Edit: Actually, I've noticed something peculiar. Each time I select an item from a ComboBox, the other ComboBoxes for the other records also change to the same item. I think this has to do with cboFiles being unbound. Changing it to bound doesn't seem to be quite right though as it just gives the same default values as txtFiles while the items are still just copied from the first cboFiles. Also, I can't actually select any of the items when it's bound. I imagine it might have to do with the read-only attributes of a linked Excel File.
Last edited: