Very basic IF question

  • Thread starter Thread starter Veli Izzet
  • Start date Start date
V

Veli Izzet

Hi all,

I want to use an if statement in a VB event for the following in English:

If BelgeNo starts with "T-" open Report1, else open Report2.

Very basic, but I need help.

Thanks for the help.
 
Hey Veli!

if left(belgeno,2)="T-" then
docmd.openreport "Report1",acpreview
else
docmd.openreport "Report2",acpreview
end if

hth,

Nick
 
If Left(BelgeNo, 2) = "T-" Then
DoCmd.OpenReport "Report1", acViewPreview
Else
DoCmd.OpenReport "Report2", acViewPreview
End If

It's even possible to do it in a single line, using an IIf statement:

DoCmd.OpenReport IIf(Left(BelgeNo, 2) = "T-", "Report1", "Report2"),
acViewPreview
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top