an if formula in visual basics to print different reports

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I hope i'v chosen the correct discussion group!!

My problem is quite simple. I'm not so familiar with visual basics code and
i just want to know something. I have this if on on click event of a command
button

If Me.Status_ID = "Accepted" Then
stdocname="Mcr View accepted letter"

End If

If Me.Status_ID = "Accepted" And Me.Student Country = "France" Then
stdocname="Mcr View accepted letter in French"

End If

Basically if a student is accepted into the college they get an acceptance
letter but the french students get theirs in french. This works fine except
that when i click on the command button for a french girl then both the
english and the french letter open. How do i put in the first if that if
me.status_ID = "Accepted" AND STUDENT COUNTRY IS NOT FRANCE?!

Thanks so much.
 
if status_id="accepted" then
if [student country] = "France" then
stdocname="Mcr View accepted letter in French"
else
stdocname="Mcr View accepted letter"
end if
end if

I suspect you have more code inside the If statements, because what you
quote here does not open letters (reports, I think).
 
Do you have DoCmd.OpenReport statements immediately following the
stdocname= statements? If you do, that is the reason why multiple
letters are printing. The first prints because the status_id =
'accepted', the second because status_id = 'accepted' AND country =
'France'. The second If...Then does not negate the first. You will need
to go with either a nested If...then as in...

If Me.Status_Id = "Accepted" then
stdocName = "whatever"
If Me.Country = "France" then
stDocName = "French Letter'
end if
End if
 
Thanks that did it!

David C. Holley said:
Do you have DoCmd.OpenReport statements immediately following the
stdocname= statements? If you do, that is the reason why multiple
letters are printing. The first prints because the status_id =
'accepted', the second because status_id = 'accepted' AND country =
'France'. The second If...Then does not negate the first. You will need
to go with either a nested If...then as in...

If Me.Status_Id = "Accepted" then
stdocName = "whatever"
If Me.Country = "France" then
stDocName = "French Letter'
end if
End if
 
Back
Top