Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-09-09
2
Medium Priority
?
456 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

730 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