Solved

Form Navigation and jump to next form and same record set- GotoItem

Posted on 2014-09-09
2
444 Views
Last Modified: 2014-09-11
Hi

I currently have a simple database where I am using a list box on the Form HomeScreen displaying a list of records  disabled for edits and a Form Detail Screen which is editable and contains all the attributes per record.  Both forms are sourced from a main table, the former displayed via a summary query

I hoped to develop a double click on the the Form Home Screen record to return the corresponding record information in the Form detail.  This failed to pull out the corresponding record on the other form and the code seems to display an error at the last moment - "Application0defined or object -defined error
This code works in a previous database.  I do not know why this is failing as the ID field is a primary key and foreign key.

Code:
'-----Public--

Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Public Type POINTAPI
    x As Long
    y As Long
End Type


'-Private FormHome screen --
Sub OpenPayload(ID As Integer)

DoCmd.OpenForm "PUDA Form", acNormal, , , acFormEdit, acWindowNormal, ID

Screen.ActiveForm.GotoItem ID


End Sub
-----------------------
0
Comment
Question by:yasanthax
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40314177
Are you sure you're getting the "ID" value correctly? Might way to place a Breakpoint in the code to see what is happening just before the OpenForm call.

Also, you're using the OpenArgs method it would seem, so do you have code in "PUDA Form" to handle that? Using GoToItem is ... fragile, at best, and you should be using a more robust solution to insure that your form is moving to the correct record. In most cases, you'd use code in the Load event to move the form to the correct record:

Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
rst.FindFirst "ID=" & Me.OpenArgs
If Not rst.NoMatch Then
  Me.Bookmark = rst.Bookmark
End If
0
 

Author Closing Comment

by:yasanthax
ID: 40317525
Brlliant. This works now when I paste the code to the second forms on load or on open event. Thanks for teaching me the OpenArgs method
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question