CLose Form A when open FormB (1 Viewer)

chrisjames25

Registered User.
Local time
Today, 17:00
Joined
Dec 1, 2014
Messages
401
Hi.

I am trynig to open a editform by clicking a cmd button within a subform of an Addform.

When it opens i need to transfer various data and then close the Addform. Achieved it all other than the close form. Any help would be great

Code:
Private Sub Cmd_EditCategory_Click()

DoCmd.OpenForm "Frm_genusEdit"
Forms.frm_genusedit!Cbo_Category.Value = Me.Category_ID
Forms.frm_genusedit!Cbo_Genus.Enabled = True
Forms.frm_genusedit!Cbo_Genus.Value = Me.Genus_ID

Forms.frm_genusedit.Form.Requery
'Forms.frm_genusedit.Cmd_EditGenus.Enabled = False
Forms.frm_genusedit.Chk_GenusActive.Value = Forms.frm_genusedit.Chk_GenusActiveBound
Forms.frm_genusedit.Cmd_EditGenus.Enabled = False
Forms.frm_genusedit.Chk_GenusActive.Enabled = True
Forms.frm_genusedit.Cbo_Genus.Enabled = False
Forms.frm_genusedit.Cbo_Category.Enabled = False
Forms.frm_genusedit.Cmd_CloseForm.Enabled = False
Forms.frm_genusedit.Cmd_EditGenusName.Enabled = True
Forms.frm_genusedit.Cmd_EditGenusName.SetFocus
Forms.frm_genusedit.Cmd_ChangeGenus.Enabled = True
Forms.frm_genusedit.Cmd_Reset.Enabled = True

End Sub

Cheers
 

Minty

AWF VIP
Local time
Today, 17:00
Joined
Jul 26, 2013
Messages
10,371
Have I got your process flow correct here ?
Open form in data add mode,
Set various values based on the calling form,
Close the form - hence saving the new record.

If so you don't really need the form - you could simply do run a SQL Insert from the original form.
 

chrisjames25

Registered User.
Local time
Today, 17:00
Joined
Dec 1, 2014
Messages
401
HI Minty

THe first form is used to add new varieties to the variety table. On the same form is a subform that shows existing varieties just for reference. But within the subform next to each variety name is a cmd button so that if a spelling mistake or desirte to change a name arises you can click the button and it will open the edit variety form and populate the intial boxes on that form with the relevant info.

THis is instead of the person noticing a spelling error and closing addform and then opening editform and then locating the variety to edit.

Admittedly it is rarely going to be used but i liked it as a nice add on to the form.

HOpe that explanis a bit better
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:00
Joined
May 7, 2009
Messages
19,247
Its a subform while would you want to close it. Anyway, detting the subforms Source Object to blank closes it. But it will leave a "hole" on your form.
 

chrisjames25

Registered User.
Local time
Today, 17:00
Joined
Dec 1, 2014
Messages
401
Apologies i want the whole of addvariety including the subform to close and only editvariety form to be open
 

Users who are viewing this thread

Top Bottom