Open Different reports from 1 form

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

Guest

Dear All
I want to open 3 different reports from 1 form. If the user types A1, A2 or
A3 in the "input" control I want Report100 to open. If he types A4, A5 or A6
I want Report200 to open etc. How can I do this?

I hav tried to use a macro with a where condition, ie [Forms]....[Input] =
"A1" or "A2" or "A3"......Open report100, but no matter what I type in the
"input" control the macro always opens report100.

My knowledge of code is limited, I grew up on macros! But if someone can
give me the code that would be great.
 
Hi Sarah,

Try using following code in the LostFocus event of your "Input1".

Private Sub Input1_LostFocus()
Dim stDocName As String
If Input1.Value = "A1" Or Input1.Value = "A2" Or Input1.Value = "A3"
Then
stDocName = "Report100"
ElseIf Input1.Value = "A4" Or Input1.Value = "A5" Or Input1.Value =
"A6" Then
stDocName = "Report200"
End If
DoCmd.OpenReport stDocName, acPreview
End Sub

Sumit
 

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