I keep getting a "Run-time error '2465' message. Access can't find the field '|1' referred to in your expression" error message.
Here is my code. I'm guessing I have the syntax wrong somewhere.
The purpose: I'm not very good at articulating what I'm trying to say, but I'll try my best. I'm writing code to append new records of additional soil samples that have been drilled for soil borings that have already been drilled. For example, if a boring was originally drilled to 20 feet, and all samples down to 20 feet were populated, and then drillers went back and drilled down to 40 feet, then I need code to populate/append the samples for the additional 20 to 40 feet drilled. The strSQL automatically identifies these borings by comparing the depth of the deepest sample to the depth of the borings. The query design works correctly, but I can't seem to get it to work in VBA.
Sample lengths are 2 feet long, so for a boring drilled to 20 feet, the deepest sample would be 18 feet.
MaxSampleDepth: Max(Samples.SampleDepth (18) + Samples.SampleLength (2)) = 20
Boring Depth = 20
Therefore, MaxSampleDepth = Boring Depth, so no additional samples need to be added for this boring.
But for a boring that was drilled to 20 feet, then later drilled to 40 feet, the query compares these values to find that new samples between the depths of 20 to 40 should be appended to this boring.
Here is my code. I'm guessing I have the syntax wrong somewhere.
Code:
strSQL = "SELECT Borings.BoringID AS bBoringID, Borings.HoleDepth, Borings.[Continuous To] AS ContTo, Borings.[Every Other] AS EveryOther, Borings.[Sample Length] AS bSampleLength, Borings.[Manual Sampling] AS ManualSampling, Max([Samples].[Depth]+[Samples].[Length]) AS MaxSampleDepth, Max(Samples.Number) AS MaxSampleNumber " _
& "FROM Borings " _
& "INNER JOIN Samples " _
& "ON Borings.BoringID = Samples.BoringID " _
& "GROUP BY Borings.BoringID, Borings.HoleDepth, Borings.[Continuous To], Borings.[Every Other], Borings.[Sample Length], Borings.[Manual Sampling], Borings.ProjectID " _
& "HAVING Borings.HoleDepth <> 0 AND Borings.[Manual Sampling] = False AND Max([Samples].[Depth]+[Samples].[Length]) < " & [Borings].[HoleDepth] & " AND Borings.ProjectID = " & [TempVars]![tmpProjectID] & ""
The purpose: I'm not very good at articulating what I'm trying to say, but I'll try my best. I'm writing code to append new records of additional soil samples that have been drilled for soil borings that have already been drilled. For example, if a boring was originally drilled to 20 feet, and all samples down to 20 feet were populated, and then drillers went back and drilled down to 40 feet, then I need code to populate/append the samples for the additional 20 to 40 feet drilled. The strSQL automatically identifies these borings by comparing the depth of the deepest sample to the depth of the borings. The query design works correctly, but I can't seem to get it to work in VBA.
Sample lengths are 2 feet long, so for a boring drilled to 20 feet, the deepest sample would be 18 feet.
MaxSampleDepth: Max(Samples.SampleDepth (18) + Samples.SampleLength (2)) = 20
Boring Depth = 20
Therefore, MaxSampleDepth = Boring Depth, so no additional samples need to be added for this boring.
But for a boring that was drilled to 20 feet, then later drilled to 40 feet, the query compares these values to find that new samples between the depths of 20 to 40 should be appended to this boring.