473,414 Members | 1,615 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,414 software developers and data experts.

Q: How to open subform to particular record

(acc2002)

I have a command button (cmdView) on a form (frmOverview)that needs to
open a form (frmFilmProjectAgreements) and its two subforms (control
names: fsubAgreements and fsubPayments) based on parameters on the
original form (frmOverview). The problem is navigating the subforms to
specific records.

Here's my code (frmOverview.cmdView_Click)thus far:

Dim frm1 As Form
Dim frm2 As Form
Dim rst1 As Recordset
Dim rst2 As Recordset

DoCmd.OpenForm "frmFilmProjectAgreements", _
WhereCondition:="[lngFilmprojectID] = " & Me.lngFilmProjectID

Set frm1 = Forms!frmFilmProjectAgreements!fsubAgreements.Form
Set frm2 = Forms!frmFilmProjectAgreements!fsubPayments.Form
Set rst1 = frm1.RecordsetClone
Set rst2 = frm2.RecordsetClone

With rst1
.FindFirst "lngFilmAgreementID = " & Me.txtFilmAgreementID
If .NoMatch Then
MsgBox "agreement not found"
Else
frm1.Bookmark = rst1.Bookmark
End If
End With

With rst2
.FindFirst "lngFilmAgreementPaymentID = " &
Me.lngFilmAgreementPaymentID
If .NoMatch Then
MsgBox "project not found"
Else
frm2.Bookmark = rst2.Bookmark
End If
End With
What happens:
frmFilmProjectAgreements opens to the correct lngFilmProjectID. The
highlighted tips in code "me.txtFilmAgreementID" and
"Me.lngFilmAgreementPaymentID" display the correct IDs, but
fsubPayments does not navigate to the right ID
(lngFilmAgreementPaymentID)...sometimes it even displays "project not
found", even though there is as its tool tip shows.

Any suggestions?
PS: the tool tip thing i keep referring to is the floating tip in VBA
when the code execution is broken.
Nov 12 '05 #1
1 10653
I think the problem you are having is caused by your using
RecordsetClone for the subforms. Clone recordsets are detached from the
GUI and are used for behind-the-scenes actions. You, in contrast, want
to position your GUIs accordingly. Use Recordset properties:

Set rst1 = frm1.Recordset
Set rst2 = frm2.Recordset

and everything should work fine. When you move inside Form.Recordset,
your subform will navigate too.
As for the ""project not found" cases, step through the code to see why.

Good luck,
Pavel

John wrote:

(acc2002)

I have a command button (cmdView) on a form (frmOverview)that needs to
open a form (frmFilmProjectAgreements) and its two subforms (control
names: fsubAgreements and fsubPayments) based on parameters on the
original form (frmOverview). The problem is navigating the subforms to
specific records.

Here's my code (frmOverview.cmdView_Click)thus far:

Dim frm1 As Form
Dim frm2 As Form
Dim rst1 As Recordset
Dim rst2 As Recordset

DoCmd.OpenForm "frmFilmProjectAgreements", _
WhereCondition:="[lngFilmprojectID] = " & Me.lngFilmProjectID

Set frm1 = Forms!frmFilmProjectAgreements!fsubAgreements.Form
Set frm2 = Forms!frmFilmProjectAgreements!fsubPayments.Form
Set rst1 = frm1.RecordsetClone
Set rst2 = frm2.RecordsetClone

With rst1
.FindFirst "lngFilmAgreementID = " & Me.txtFilmAgreementID
If .NoMatch Then
MsgBox "agreement not found"
Else
frm1.Bookmark = rst1.Bookmark
End If
End With

With rst2
.FindFirst "lngFilmAgreementPaymentID = " &
Me.lngFilmAgreementPaymentID
If .NoMatch Then
MsgBox "project not found"
Else
frm2.Bookmark = rst2.Bookmark
End If
End With

What happens:
frmFilmProjectAgreements opens to the correct lngFilmProjectID. The
highlighted tips in code "me.txtFilmAgreementID" and
"Me.lngFilmAgreementPaymentID" display the correct IDs, but
fsubPayments does not navigate to the right ID
(lngFilmAgreementPaymentID)...sometimes it even displays "project not
found", even though there is as its tool tip shows.

Any suggestions?
PS: the tool tip thing i keep referring to is the floating tip in VBA
when the code execution is broken.

Nov 12 '05 #2

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

Similar topics

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...
1
by: edself | last post by:
I have a form which displays a subform datasheet of information. I'd like to be able to quickly click on a particular record and open up another form showing more detailed information about that...
1
by: Richard | last post by:
Thats a mouthfull of a title what I'm after should be really simple. I have a form with a subform which itself has a subform the final subform contains an individuals record. The individuals...
2
by: Simon P | last post by:
Hello group, I'm in desperate need of help. Here goes : I have the following tables : CONTACTS (ContactID, FirstName, LastName, Company, etc.), SHOWS (ShowID, ShowDescription) and SHOWDETAILS...
5
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test...
1
by: perryche | last post by:
All, I posted this earlier yesterday and here is more situation. Thanks to David, by the way, for his codes here. It kinds of work, but not always. I have a MainForm with a subform. When I...
5
by: Thelma Lubkin | last post by:
I have a form/subform with the common one-to-many relationship. The form allows user to display records and move to other records via the selector, to add,delete, and edit them, with the related...
2
by: nkoske | last post by:
I have a form with a subform in datasheet view and I have a event on one of the fields in the subform, so that the user can double click it and go to expanded information based on that field. ...
6
by: erick-flores | last post by:
Hello all, Form A & Form B Form B opens when I click on a button from Form A. How do I setup Form B so it will always let me insert new records. Because right know, when I click on the button...
4
by: Leah Trahan | last post by:
I am new at Access, databases, AND posting threads (sorry). I have a subform that is a continuous form based on a tabular query. I enter a particular serial # (on the main form) and the subform...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.