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

Closing a form linked to criteria in a parent form 1

Status
Not open for further replies.

JferWfer

IS-IT--Management
Sep 18, 2002
16
US
Hi, I am new to access coding and need to figure out how to close parent forms when a subform is opened and retain the record that was on the parent form. This database will have many forms and since the users have older computers I don't want any additional forms open than are necessary. I have used wizards to create buttons that open the subform with the filtered record, however the parent forms stays open. Below is the coding for one of "these" buttons, I assume it would be a DoCmd.Close and the Form Name but that did not seem to work, I also tried creating my own macro with the a where statement but the child form comes up blank. Any help would be truly appreciated.

Thanks, Jennifer

Private Sub FindCustomerInformation_Click()
On Error GoTo Err_FindCustomerInformation_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "CustomerInformation"

stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_FindCustomerInformation_Click:
Exit Sub

Err_FindCustomerInformation_Click:
MsgBox Err.Description
Resume Exit_FindCustomerInformation_Click

End Sub
 
Hi Jennifer,

you can use the docmd.closeform "Mainform" command in the OnLoad property of the subform (CustomerInformation ?) - that should work.

Greetings,

Vincent
 
Hi

You can create a close form button with the wizard:

Private Sub cmdExit_Click()
On Error GoTo Err_cmdExit_Click

DoCmd.Close

Exit_cmdExit_Click:
Exit Sub

Err_cmdExit_Click:
MsgBox "Error " & err.description
Resume Exit_cmdExit_Click
End Sub Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top