Proper Code?

J

John

I have a form with a command button that opens another form. The forms are
frmProjectCost (parent form), and frmJobTotal (Child). When the command
button is clicked on the parent form, I want to hid it from view. In the "on
click" event I put the following code:

Me.Form.Visible = False
DoCmd.OpenForm "frmJobTotal", acNormal, , , acFormEdit, acWindowNormal

This hides the parent form and launches the chile. I want to hide the parent
because it has data on it I would like to use on the child form. So the
question is, How do I get data from the parent form? Is the syntax:

forms!frmProjectCost.cmdCurMon.value

to get the value of the command button cmdCurMon?

Also, when the users exits the child form, how shoud I make the parent form
visible again? What I did was add this to the "on close" event:

Private Sub Form_Close()
If CurrentProject.AllForms("frmProjectCost").IsLoaded Then
Forms!frmProjectCost.Visible = True
Else
DoCmd.OpenForm "frmProjectCost", acNormal, , , acFormReadOnly
End If
End Sub
 
R

Rick Brandt

John said:
I have a form with a command button that opens another form. The
forms are frmProjectCost (parent form), and frmJobTotal (Child).
When the command button is clicked on the parent form, I want to hid
it from view. In the "on click" event I put the following code:

Me.Form.Visible = False
DoCmd.OpenForm "frmJobTotal", acNormal, , , acFormEdit,
acWindowNormal

This hides the parent form and launches the chile. I want to hide the
parent because it has data on it I would like to use on the child
form. So the question is, How do I get data from the parent form? Is
the syntax:

forms!frmProjectCost.cmdCurMon.value

to get the value of the command button cmdCurMon?

CommandButtons don't have a value. Do you mean a ToggleButton?
Also, when the users exits the child form, how shoud I make the
parent form visible again? What I did was add this to the "on close"
event:

Private Sub Form_Close()
If CurrentProject.AllForms("frmProjectCost").IsLoaded Then
Forms!frmProjectCost.Visible = True
Else
DoCmd.OpenForm "frmProjectCost", acNormal, , , acFormReadOnly
End If
End Sub

That looks good to me? Does it work?
 
J

John

Rick,

Yes, sorry it's a combo box, not a command button.

The code seem to work fine. I was just wondering if there were a better
way. I am new to all this and I could not find any documentation on how to
reference forms that were open but not currently active. If you have more
than one form open the "Me. --- " doesn't exactly work.

Thanks!
 

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

Top