473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Open a 2nd form from a 1st form and keep the same rs and current record

I would like to open a columnar form (so I can see all the details)
from a datasheet form (so I can see what is there) but keep the same
recordset and current record.

I can do the recordset set part (stlinkcriteria) - but how do I have
the new form open on the record that was current in the datasheet form?

I don't want to filter to the current record when the 2nd form opens -
I would like to be able to keep the whole rs and be able to go back and
forward to the other records.

Nov 13 '05 #1
1 2941
"4004" <m.********@ntlworld.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I would like to open a columnar form (so I can see all the details)
from a datasheet form (so I can see what is there) but keep the same
recordset and current record.

I can do the recordset set part (stlinkcriteria) - but how do I have
the new form open on the record that was current in the datasheet form?

I don't want to filter to the current record when the 2nd form opens -
I would like to be able to keep the whole rs and be able to go back and
forward to the other records.

The trick to this, is to write code in the second form's open event. This
code assumes that there is a table of contacts with a primary key ConID
which is a long integer (if the primary key is text then the code needs to
be adjusted slightly).
Private Sub Form_Open(Cancel As Integer)

On Error GoTo Err_Handler

Dim strOpenArgs As String

strOpenArgs = Trim(Nz(Me.OpenArgs, ""))

If Len(strOpenArgs) > 0 Then

Cancel = True

With Me.RecordsetClone

.FindFirst "ConID=" & strOpenArgs

If Not .NoMatch Then
Me.Bookmark = .Bookmark
Cancel = False
Else
MsgBox "Cannot locate contact no: " & strOpenArgs, _
vbExclamation, _
"Record location error"
End If

End With

End If

Exit_Handler:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub
Once this code is in there, you can then open the contacts form at a
particular record by calling
Docmd.OpenForm "frmContact",,,,,,"203"
Where "203" is an example ContactID, which, of course, would come from the
first form in your case.
If you don't supply a contact id, the form simply opens as normal. If you
do, then it will only open if it locates that record.

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andras Gilicz | last post by:
Hi VB fans I'm working on a relatively large project in VB6 with about a dozen forms, including graphs, labels, text boxes, etc. The software itself is actually a flow simulator with more or...
55
by: Steve Jorgensen | last post by:
In a recent thread, RKC (correctly, I believe), took issue with my use of multiple parameters in a Property Let procedure to pass dimensional arguments on the basis that, although it works, it's...
4
by: Dalan | last post by:
I presume that using an open recordset method is the preferred method of accomplishing what I'm trying to do. Of course, if there are other options that would work, feel free to share them. I...
1
by: SorboPos | last post by:
Hi. I have a form with continuous forms and a data entry section in the header of the form. (I.e. all transactions show in the main form area like a data sheet and the data for the highlighed...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
6
by: Esteban404 | last post by:
I'm trying to create a preview shot of a record being edited, so I want to take the current state and pass it to a instance of a form I have. I've tried to create a dataView and pass that, but it...
1
by: NumberCruncher | last post by:
Hi All, I am struggling with setting up my first system of tables, forms,and reports, and could use your help! I am setting up a database to keep track of the production of a produced item. The...
1
by: cbanks | last post by:
Hello Ladies/Gents, im in need of some serious help here.. I have a tool that allows users to view information on a form and make changes to recordsets. This tool has buttons that allow a user to...
9
by: vanlanjl | last post by:
Okay lets see if I can do this with out confusing myself or others. First I will give ALL the details then state my problem and request at the bottom. Tables: tblContacts ID Company LastName...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.