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

Open a Continuous form with previos record at top of list

Status
Not open for further replies.

randifprf

Technical User
Aug 22, 2004
11
US
I am using a continous form to go to other detailed forms. I have the continuous form close so updated field are shown when I return. The problem is, it returns with all records showing in it's original sort order. I have also tried this code,

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Customer Phone List"
stLinkCriteria = "[ContactID]=" & Me![ContactID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.Close acForm, "Contacts"

On a Close Button but in the Contacts form and only get the one record showing. Can I pass the ContactID to a
DoCmd.GoToRecord in the On Open event of the Customer phone list.
 
Yes, but do this...

Dim intID As Integer

intID = Me.ContactID 'from continuous form

DoCmd.OpenForm "Customer Phone List"
Me.ContactID.SetFocus

DoCmd.GoToRecord intID
 
...forgot to say..

put this in clickEvent of commandButton from 1st form(continuous)
 
Not Sure I Understand
Here is how I have it now
Continuous Form Code to open Contacts;

Private Sub CompanyName_DblClick(Cancel As Integer)
On Error GoTo Err_CompanyName_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Contacts"

stLinkCriteria = "[ContactID]=" & Me![ContactID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Maximize
DoCmd.Close acForm, "Customer Phone List"

Exit_CompanyName_Click:
Exit Sub

Err_CompanyName_Click:
MsgBox Err.Description
Resume Exit_CompanyName_Click

End Sub


Then From Contacts Close Button

Private Sub CmdCloseCnts3_Click()
On Error GoTo Err_CmdCloseCnts3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Customer Phone List"
stLinkCriteria = "[ContactID]=" & Me![ContactID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.Close acForm, "Contacts"


Exit_CmdCloseCnts3_Click:
Exit Sub

Err_CmdCloseCnts3_Click:
MsgBox Err.Description
Resume Exit_CmdCloseCnts3_Click

End Sub


I get just the 1 record when returning.
I use this process to move around alot so One fix can help me throughout.
TYIA


 
Private Sub CmdCloseCnts3_Click()
On Error GoTo Err_CmdCloseCnts3_Click

Dim stDocName As String
Dim IntId As integer

stDocName = "Customer Phone List"
intID = Me![ContactID]
DoCmd.OpenForm stDocName

Me.ContactID.SetFocus

DoCmd.GoToRecord intID

DoCmd.Close acForm, "Contacts"


Exit_CmdCloseCnts3_Click:
Exit Sub

Err_CmdCloseCnts3_Click:
MsgBox Err.Description
Resume Exit_CmdCloseCnts3_Click

End Sub
 
Sorry, I still haven't quite got it.
I'm going from "Customer Phone list" (Continuous form] to
"Contacts" (Single Form)

I can go ther fine with this

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Contacts"
stLinkCriteria = "[ContactID]=" & Me![ContactID]

DoCmd.OpenForm stDocName, , , stLinkCriteria


DoCmd.Close acForm, "Customer Phone List"

When I return from Contacts with this

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Customer Phone List"
stLinkCriteria = "[ContactID]=" & Me![ContactID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.Close acForm, "Contacts"

It opens with only The one record showing, I would like to have it with other records there also.

I've been trying what you suggested but I must have something set wrong.
Trying that, I get a Run-time error '2487'
The Object Type argument for the action is blank or invalid.


 
I'm sorry, I meant ...

Docmd.FindRecord intID
 
How are ya randifprf . . . . .
randifprf said:
[blue]I have the continuous form close so updated field are shown when I return.[/blue]
Ya don't have to close the form! [blue]In fact dont[/blue]. Try this (assuming ContactID is numeric):
[ol][li]The call to open the [blue]details form[/blue] should be ([blue]you1[/blue] substitute proper names in [purple]purple[/purple]):
Code:
[blue]   DoCmd.OpenForm "[purple][b]FormName[/b][/purple]", , , , , , Str(Me!ContactID)[/blue]
[/li]
[li]In the [blue]UnLoad[/blue] event of the details form, copy/paste the following:
Code:
[blue]   Call UpdateOnRtn(Me.OpenArgs)[/blue]
You use this call in each detail form.[/li]
[li]In a [blue]module[/blue] in the [blue]modules window[/blue], copy/paste the following routine:
Code:
[blue]Public Sub UpdateOnRtn(OpnArg)
   
   If Trim(OpnArg & "") <> "" Then [green]'Allows opening form independently.[/green]
      Dim frm As Form, rst As DAO.Recordset
      
      Set frm = Forms!Contacts
      frm.Requery
      Set rst = frm.RecordsetClone
      
      If Not rst.BOF Then
         rst.FindFirst "ContactID = " & Val(OpnArg)
         If Not rst.NoMatch Then frm.Bookmark = rst.Bookmark
      End If
      
      Set rst = Nothing
      Set frm = Nothing
   End If

End Sub[/blue]
[/li][/ol]
[purple]Thats it . . . give ita whirl & let me know . . .[/purple]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top