Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open form based on value in a field

Status
Not open for further replies.

delta456

Programmer
Jul 25, 2008
1
US
Hi

I have one form that is based on a table with only one records in it. On this form, I want to evaluate the value in the Environment field. If the value = "TEST" then I want to open one form, if the value in the field is "DEV" then I want to open a different form. I am trying to do this on the close function of the first form.

So far i have
Private Sub Form_Close()
if me.environment = "TEST" then
docmd.openreport rpt_recon_summary_hdr, acviewnormal
else
docmd.openreport rpt_recon_summary_trans,acviewnormal
end if

end sub

I am getting an error run-time error '13'
type mismatch on the line of if me.environment = "TEST"

any suggestions.
thanks
 
Private Sub Form_Close()
If Me![environment] = "TEST" Then
DoCmd.OpenReport "rpt_recon_summary_hdr", acViewPreview
Else
DoCmd.OpenReport "rpt_recon_summary_trans", acViewPreview
End If
End Sub

You forgot the "'s and you want acViewPreview
 
How are ya delta456 . . .

First, you should move your code to the forms [blue]On UnLoad[/blue] event. All your form controls are still in scope here (accessible!).

Now:
delta456 said:
[blue]If the value = "TEST" then [purple]I want to open one form[/purple], if the value in the field is "DEV" then [purple]I want to open a different form[/purple].[/blue]
You say you want to open forms but your code uses the [blue]OpenReport[/blue] method of [blue]DoCmd![/blue] You'll have to switch to the [blue]OpenForm[/blue] method and [blue]set syntax proper[/blue] if you really meant forms.

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
delta456,

Did any of this ever work for you? What did you end up with for a solution?

--

"If to err is human, then I must be some kind of human!" -Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top