Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-09-09
2
Medium Priority
?
462 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
2 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

782 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