Solved

Passing bookmark or active record to another form

Posted on 2004-10-08
8
184 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

810 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