Link to home
Start Free TrialLog in
Avatar of seanlhall
seanlhallFlag for United States of America

asked on

How can I hide a form when closing and opening another?

I have a main form called "frmMainHome" it has a subform called " frmSubUpdates". On the subform there is a button that closed the main form "frmMainHome" and opens another form called"frmsubjectedit" The problem is when I click the button to open "frmsubjecteidt" , frmMainform is still present as the new form is opening. How can i referr to the parent form form teh subform to hide before it closes and opens frmsubjectedit. i am looking from a cleaner look. The cose is from the subform event.
Dim stDocName As String
Dim stLinkCriteria As String
Dim subjectid As String
subject = Me.subjectid
stLinkCriteria = "casestatus = 'Open'"
stStatusCriteria = """Open"""
stDocName = "frmsubjectedit"
   
stLinkCriteria = "subjectid=" & subject
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit, OpenArgs:="frmMainHome" & ";" & stStatusCriteria
DoCmd.Close acForm, "frmMainhome"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of pteranodon72
pteranodon72
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeffrey Coachman
<No Points wanted>

There are other ways to do this that are more complicated as well.
You can search here for your question text for some examples
(Like storing the previous form's name and closing it, ...etc)

pteranodon72 has covered the most popular, so go with that...


;-)

JeffCoachman
pteranodon72,

I try to only use the Echo method if I am using a version of Access prior to when the hidden argument was available.
(I believe the hidden argument was around a long time in Forms, but this argument was first introduced in Reports in Access 2002, I think...)

You also need a good error handler, to turn the screen back on in case of an error...
;-)

Jeff

Avatar of seanlhall

ASKER

Excellent!!