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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Form If Value = Yes

Status
Not open for further replies.

roystreet

Programmer
Oct 12, 2000
146
US
Hello,
I made a one field table that either holds a value of Yes or No (currently- Later it will get more complex) I have a form in which a user selects from a drop down (limited to list) yes or no. How I have it set up is when the welcome splash form opens when the database opens, it will run an on-timer event. It will check the invisible field on welcome form to see if the value = yes. If it does then it should open a specific form, else end if. My desire & I may be going at this the wrong way it to allow a user to set via a control form whether they want to view a specific form upon the closing of the welcome form. I checked the below code via another form and ran it on an onclick event - Worked just fine. But when the on timer event goes, it doesn't open the specific form (and the value currently in there is yes) and it opens the debugger highlighting the first line of the if statement. Not sure why it's doing this? Any ideas?
Below is the code I have on the on timer event.

Code:
If txtOpenForm = "Yes" Then
    DoCmd.openForm "frm-test", acNormal, "", "", , acNormal
End If

Thanks,
---roystreet
 
Have you tried this ?
If txtOpenForm Then

BTW, any error message before the debug window ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Howdy,
I think I figured it out...I also had the on timer event open a couple of other forms, but I didn't put them in the if statement since those open by default and the users don't get a choice if those open or not. Once I included those in the if statement it appears to work now. I didn't know that they had to be included with that, I thought that those could still be separate since they aren't determined by another value. Is this true? If so, I do need to remember this the next time.

Thanks,
---roystreet

My Code Now Looks Like This:
Code:
Private Sub Form_Timer()
If txtOpenForm = "Yes" Then
    DoCmd.Close
    DoCmd.openForm "ControlPanel", acNormal, "", "", , acNormal
    DoCmd.openForm "frm-test", acNormal, "", "", , acNormal
    DoCmd.openForm "frm_QuickList_Reminder", acNormal, "", "", , acNormal

    
Else

    DoCmd.Close
    DoCmd.openForm "ControlPanel", acNormal, "", "", , acNormal
    DoCmd.openForm "frm_QuickList_Reminder", acNormal, "", "", , acNormal

End If
End Sub

**Before the open form for control panel and frm_quicklist were separate.
 
Hello Again,
I went an extra 'mile' with this and ultimaately what I was trying to do was allow the user to dictate what forms would open when the DB opens. Since above worked, I went ahead on a main contents form have a few drop down menus. The values would then be saved a brand new table. The splash welcome form opens which draws its data from the table. It then ontime event checks a series of if then statements checking to see if certain values are yes, if yes then open this form, else basically leave it alone. I was having a debugger come open. I am home and I would have to reproduce this whole thing to work on it right this minute. Is there a better way at doing this? I remember, the debugger would open and highlight the if statement which looks much like the one above. So, I didn't see what the problem was - I then placed an apotrophe next to that whole statement just in case that was causing an error. Then, it would open the debugger and highlight the next if statement. So, it's something that has to do with practically all of the if statements.

By the way, PHV thanks for the help.
Any Ideas,
---roystreet
 
Again, any error message before the debug window ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top