Solved

Passing bookmark or active record to another form

Posted on 2004-10-08
8
183 Views
Last Modified: 2010-05-02
Please help:

I am having problems with a new form not being able to draw the proper information from the table.

I need the form to display the information on a record that the user had selected on a previous form.

In my current method, I have a book mark set to the proper record, and the new form would read from that record upon opening.  Unfortunately, the book mark seems to be reset every time.

I was told that this may be solved multiple ways, such as using a sub form instead of a stand alone form.

Does anyone have any suggestions?  Thanks for the help.
0
Comment
Question by:antaren
  • 2
  • 2
8 Comments
 
LVL 8

Expert Comment

by:mladenovicz
ID: 12259175
Did you pass recordset to another form?
0
 

Author Comment

by:antaren
ID: 12263570
Unsure, what method would I use to do that?
0
 
LVL 8

Accepted Solution

by:
mladenovicz earned 250 total points
ID: 12265540
Maybe I didn't understand you properly but try this,

To form (I will call it frmDisplayRecord) that should display record add this function

Public Function ShowRecord(adoRecord As ADODB.Recordset)
    Dim adoField As ADODB.Field
   
    For Each adoField In adoRecord.Fields
        Debug.Print adoField.Name, adoField.Value
    Next
End Function

On main form when you select a record call
frmDisplayRecord.ShowRecord YourRecordset

YourRecordset is positioned on the record you want to display.

HTH
0
 
LVL 3

Assisted Solution

by:Noel_Castillo
Noel_Castillo earned 250 total points
ID: 12274403
If you are opening two seperate recordsets on different form, bookmark wont work even if the two recordsets refers on the same table(in database). This is because a recordset creates its own set of bookmarks.

One way of doing this is by passing the actual recordset from the original form(display form) to the form where the user will select the record. Create a function in your in your lookup form(where record selection occurs) that accepts a recordset as its parameter.

'Create this function in the lookup form named frmLookUp
Public Function LookUp(ByRef rs as ADODB.Recordset) As Boolean
     Me.Show 1  'lookupform needs to be modal to hault until a user selects a record
     'Any movement done in the lookup form will reflect in the calling form.
End Function


'Call the function from the original form.
frmLookUp.LookUp OrigRS
'OrigRS will be set by the function (points to the row selected by the user)

:) i hope this helps
0
 
LVL 3

Expert Comment

by:Noel_Castillo
ID: 12562089
treating a form as a function as i shown above for some generic tasks is a good programming style(i think). But still its up to you on whats you're confortable using with.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 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

15 Experts available now in Live!

Get 1:1 Help Now