I am trying to use the variable strTest as a variable in the select statement below.
The fields in the custody database contain F8 thru F34.
Private Sub txtMethod_BeforeUpdate(Cancel As Integer)
strA = 8
Do While strA < 35
strTest = "F" + strA
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Select strTest from Custody where LABID = '" & Me.txtLabID & "' AND strTest = '" & Me.txtMethod & "';")
strA = strA + 1
Loop
If rst.RecordCount = 0 Then
MsgBox Me.txtMethod + " is not required for Lab ID: " + Me.txtLabID
End
End If
End Sub
If I substitute this line of code:
Set rst = dbs.OpenRecordset("Select F8 from Custody where LABID = '" & Me.txtLabID & "' AND F8 = '" & Me.txtMethod & "';")
the line works just fine.
Obviously I would like to avoid repeating the line 26 times changing F8 to F9 to F10......
I also tried to use an if then statement in a loop with a counter.
The bottom line: I have not been able to reference the variable to see the contents of fields F8 - F34
As always, any help is greatly appreciated.
Thanks,
B
The fields in the custody database contain F8 thru F34.
Private Sub txtMethod_BeforeUpdate(Cancel As Integer)
strA = 8
Do While strA < 35
strTest = "F" + strA
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Select strTest from Custody where LABID = '" & Me.txtLabID & "' AND strTest = '" & Me.txtMethod & "';")
strA = strA + 1
Loop
If rst.RecordCount = 0 Then
MsgBox Me.txtMethod + " is not required for Lab ID: " + Me.txtLabID
End
End If
End Sub
If I substitute this line of code:
Set rst = dbs.OpenRecordset("Select F8 from Custody where LABID = '" & Me.txtLabID & "' AND F8 = '" & Me.txtMethod & "';")
the line works just fine.
Obviously I would like to avoid repeating the line 26 times changing F8 to F9 to F10......
I also tried to use an if then statement in a loop with a counter.
The bottom line: I have not been able to reference the variable to see the contents of fields F8 - F34
As always, any help is greatly appreciated.
Thanks,
B