Solved

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

Posted on 2014-09-09
2
438 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 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now