G
gmazza via AccessMonster.com
Hey there,
Here is a sample of my code. I just want to know if there is an easierr way
of writing 1 IF statement, then 5 of them.
Dim VisitFlag1 As Integer
Dim VisitFlag2 As Integer
Dim VisitFlag3 As Integer
Dim VisitFlag4 As Integer
Dim VisitFlag5 As Integer
Dim VisitNo As Integer
VisitNo = Forms!Patient.Text51
Set rs = CurrentDb.OpenRecordset("Select * from VisitCriteria where
ClinicalTrialId = '" & study & "'")
If rs.RecordCount > 0 Then
rs.MoveFirst
Do While Not rs.EOF
For Each fld In rs.Fields
If fld.Name = "Visit1" Then
If fld.Value = False Then
VisitFlag1 = 0
Else
VisitFlag1 = 1
End If
End If
I am doing this for EACH Visit, 1-5
If fld.Name = "CriteriaValue" Then
If IsNull(fld.Value) Then
Else
If VisitNo = VisitFlag1 Then
intCount = intCount + 1
With Me.Controls("Label" & intCount)
.Caption = fld.Value
.Visible = True
End With
Else
If VisitNo = VisitFlag2 Then
intCount = intCount + 1
With Me.Controls("Label" & intCount)
.Caption = fld.Value
.Visible = True
End With
Else
If VisitNo = VisitFlag3 Then
intCount = intCount + 1
With Me.Controls("Label" & intCount)
.Caption = fld.Value
.Visible = True
End With
End If
End If
End If
I only did an example here for 3 visits. Is there anyway I can make this IF
in just 1 statement, since its doing the same thing anwyay, it just needs to
know what the VisitFlag equals.
Thanks for your help!
Here is a sample of my code. I just want to know if there is an easierr way
of writing 1 IF statement, then 5 of them.
Dim VisitFlag1 As Integer
Dim VisitFlag2 As Integer
Dim VisitFlag3 As Integer
Dim VisitFlag4 As Integer
Dim VisitFlag5 As Integer
Dim VisitNo As Integer
VisitNo = Forms!Patient.Text51
Set rs = CurrentDb.OpenRecordset("Select * from VisitCriteria where
ClinicalTrialId = '" & study & "'")
If rs.RecordCount > 0 Then
rs.MoveFirst
Do While Not rs.EOF
For Each fld In rs.Fields
If fld.Name = "Visit1" Then
If fld.Value = False Then
VisitFlag1 = 0
Else
VisitFlag1 = 1
End If
End If
I am doing this for EACH Visit, 1-5
If fld.Name = "CriteriaValue" Then
If IsNull(fld.Value) Then
Else
If VisitNo = VisitFlag1 Then
intCount = intCount + 1
With Me.Controls("Label" & intCount)
.Caption = fld.Value
.Visible = True
End With
Else
If VisitNo = VisitFlag2 Then
intCount = intCount + 1
With Me.Controls("Label" & intCount)
.Caption = fld.Value
.Visible = True
End With
Else
If VisitNo = VisitFlag3 Then
intCount = intCount + 1
With Me.Controls("Label" & intCount)
.Caption = fld.Value
.Visible = True
End With
End If
End If
End If
I only did an example here for 3 visits. Is there anyway I can make this IF
in just 1 statement, since its doing the same thing anwyay, it just needs to
know what the VisitFlag equals.
Thanks for your help!