Solved

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

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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…
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 …

776 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