Hi Everyone,
I have a bit of a complicated problem. I am creating a database for DNA samples. Samples are collected at a number of locations so I have one table that contains each location, and another that keeps track of each DNA collection (each collection has 100 samples). When I'm entering data for a new collection, I have a continuous form that is limited (using cascading combo boxes in the header) to all the kits for that specific location.
I have pre-assigned a range of sample numbers for each location, and this range is stored in the fishing locations table. What I would like to happen is this:
On the form, when I click on the DNA sample number start (SampleNo_Start) field, I would like it to determine the next in the sequence of sample numbers and automatically fill in the sample number start and end values. It could do this by referring to the location_ID, and then querying the table that has all the DNA collections, finding all the samples that match that location, and then finding the max sample number, and adding 1. In the event that there are no DNA collections existing for that location yet, it would go back to the fishing locations table and determine the starting sample number for the given location.
Does that make any sense?
Here's an example:
tblFishingLocations
ID Location SampleRange_Start SampleRange_End
1 Fraser_River 12001 30000
2 Haida_Gwaii 30001 35000
3 Vancouver_Island 35001 40000
tblDNACollections
Collection_ID Location_ID SampleNo_Start SampleNo_End
1 2 30001 30100
2 1 12001 12100
3 1 12101 12200
4 2 30101 30200
frmDNACollection_request
Location: 1
Collection_ID Location_ID SampleNo_Start SampleNo_End
2 1 12001 12100
3 1 12101 12200
5 (New) 1 = max(tblDNACollections!SampleNo_Start
WHERE Location = Me.Location_ID
IF no (Location_ID) in tblDNACollection then
refer to
tblFishingLocations!LocationID!SampleRange_Start
OK, obviously this is not the correct code at all, I'm just trying to convey the purpose of what I'm trying to accomplish. I am very new to VBA and access in general, and I suspect I might be taking a totally incorrect approach to this problem.
Any hints or suggestions are very much appreciated!
Erica
I have a bit of a complicated problem. I am creating a database for DNA samples. Samples are collected at a number of locations so I have one table that contains each location, and another that keeps track of each DNA collection (each collection has 100 samples). When I'm entering data for a new collection, I have a continuous form that is limited (using cascading combo boxes in the header) to all the kits for that specific location.
I have pre-assigned a range of sample numbers for each location, and this range is stored in the fishing locations table. What I would like to happen is this:
On the form, when I click on the DNA sample number start (SampleNo_Start) field, I would like it to determine the next in the sequence of sample numbers and automatically fill in the sample number start and end values. It could do this by referring to the location_ID, and then querying the table that has all the DNA collections, finding all the samples that match that location, and then finding the max sample number, and adding 1. In the event that there are no DNA collections existing for that location yet, it would go back to the fishing locations table and determine the starting sample number for the given location.
Does that make any sense?
Here's an example:
tblFishingLocations
ID Location SampleRange_Start SampleRange_End
1 Fraser_River 12001 30000
2 Haida_Gwaii 30001 35000
3 Vancouver_Island 35001 40000
tblDNACollections
Collection_ID Location_ID SampleNo_Start SampleNo_End
1 2 30001 30100
2 1 12001 12100
3 1 12101 12200
4 2 30101 30200
frmDNACollection_request
Location: 1
Collection_ID Location_ID SampleNo_Start SampleNo_End
2 1 12001 12100
3 1 12101 12200
5 (New) 1 = max(tblDNACollections!SampleNo_Start
WHERE Location = Me.Location_ID
IF no (Location_ID) in tblDNACollection then
refer to
tblFishingLocations!LocationID!SampleRange_Start
OK, obviously this is not the correct code at all, I'm just trying to convey the purpose of what I'm trying to accomplish. I am very new to VBA and access in general, and I suspect I might be taking a totally incorrect approach to this problem.
Any hints or suggestions are very much appreciated!
Erica
Last edited: