Firstly, I am a medic and not a programmer. I use access to create simple databases for my workplace. So please bear with me if my question is stupid or does not make any sense.
I have a single table data base (I know. My use of access is that basic) with a single column multivalue field 'Immunostains' in it. There is a form feeding into this table with two command buttons that save the record and print a relevant report (one for each command button - Extrawork report and Herceptest1). Now, I want to get rid of one of the command buttons and use just the one that can print both reports or only one depending on the values in the 'Immunostains' field. So if the immunostains field contained the value 'Her2' amongst others, I want both reports printed out. If this value is absent, then just the Extrawork report. I hope what I am trying to say is not complete twaddle.
Here is the code I wrote for it. It prints both reports if the value in the field is only Her2. But if there are other values with Her2, it prints only the Extrawork report. what am I doing wrong? I am sure it is do with how multivalue fields work - but it is beyond me. Any help will be greatly appreciated.
Private Sub Command33_Click()
If Me.Dirty = True Then Me.Dirty = False
If Immunostains.Value.column1 Like "*Her2*" Then
strReport = "Extrawork report"
strWhere = "[Id]=" & Me![ID]
DoCmd.OpenReport strReport, acViewNormal, , strWhere
strReport = "Herceptest1"
strWhere = "[Id]=" & Me![ID]
DoCmd.OpenReport strReport, acViewNormal, , strWhere
DoCmd.GoToRecord , , acNewRec
Else
strReport = "Extrawork report"
strWhere = "[Id]=" & Me![ID]
DoCmd.OpenReport strReport, acViewNormal, , strWhere
DoCmd.GoToRecord , , acNewRec
End If
End Sub
I have a single table data base (I know. My use of access is that basic) with a single column multivalue field 'Immunostains' in it. There is a form feeding into this table with two command buttons that save the record and print a relevant report (one for each command button - Extrawork report and Herceptest1). Now, I want to get rid of one of the command buttons and use just the one that can print both reports or only one depending on the values in the 'Immunostains' field. So if the immunostains field contained the value 'Her2' amongst others, I want both reports printed out. If this value is absent, then just the Extrawork report. I hope what I am trying to say is not complete twaddle.
Here is the code I wrote for it. It prints both reports if the value in the field is only Her2. But if there are other values with Her2, it prints only the Extrawork report. what am I doing wrong? I am sure it is do with how multivalue fields work - but it is beyond me. Any help will be greatly appreciated.
Private Sub Command33_Click()
If Me.Dirty = True Then Me.Dirty = False
If Immunostains.Value.column1 Like "*Her2*" Then
strReport = "Extrawork report"
strWhere = "[Id]=" & Me![ID]
DoCmd.OpenReport strReport, acViewNormal, , strWhere
strReport = "Herceptest1"
strWhere = "[Id]=" & Me![ID]
DoCmd.OpenReport strReport, acViewNormal, , strWhere
DoCmd.GoToRecord , , acNewRec
Else
strReport = "Extrawork report"
strWhere = "[Id]=" & Me![ID]
DoCmd.OpenReport strReport, acViewNormal, , strWhere
DoCmd.GoToRecord , , acNewRec
End If
End Sub