Close one form return to the previous one

A

Anne

I created a simple search on an existing form called FrmSales. The search
opens a search results form which was created from a query. I want the user
to be able to double click a job to select it and return to Form sales with
that job information displayed. It works, what I cannot get to work is
closing the search from. Below is the code:

Private Sub txtJobID_DblClick(Cancel As Integer)
On Error GoTo Err_JobID_Click

Dim stDocName As String
Dim stLinkCriteria As String
stLinkCriteria = "[JobID]=" & Me.txtJobID

stDocName = "FrmSales"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "FrmSalesJobSearch", acSaveYes

Exit_txtJobID_Click:
Exit Sub

Err_JobID_Click:
MsgBox Err.Description
' Resume Exit_JobID_Click

End Sub
 
B

bhicks11 via AccessMonster.com

So, is the control txtJobID on the FrmSalesJobSearch form?

You could set it to visible=no and put DoCmd.Close acForm,
"FrmSalesJobSearch", acSaveYes in the OnClose of the second form.

Bonnie
http://www.dataplus-svc.com
I created a simple search on an existing form called FrmSales. The search
opens a search results form which was created from a query. I want the user
to be able to double click a job to select it and return to Form sales with
that job information displayed. It works, what I cannot get to work is
closing the search from. Below is the code:

Private Sub txtJobID_DblClick(Cancel As Integer)
On Error GoTo Err_JobID_Click

Dim stDocName As String
Dim stLinkCriteria As String
stLinkCriteria = "[JobID]=" & Me.txtJobID

stDocName = "FrmSales"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "FrmSalesJobSearch", acSaveYes

Exit_txtJobID_Click:
Exit Sub

Err_JobID_Click:
MsgBox Err.Description
' Resume Exit_JobID_Click

End Sub
 

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