Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Close one form return to the previous one

Geek News

Close one form return to the previous one
Anne 11/20/2008 1:01:01 PM
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

Re: Close one form return to the previous one
"bhicks11 via AccessMonster.com" <u44327[ at ]uwe> 11/20/2008 2:31:17 PM
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

Anne wrote:
[Quoted Text]
>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

--
Message posted via http://www.accessmonster.com

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net