473,403 Members | 2,354 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,403 software developers and data experts.

Problem opening a Form

Lyn
Hi,
I am working on a genealogy project in which I have two tables:

Person -- one record for each person in the family. Each record has a
unique Autonum field (IDPerson).

Partnerships -- one record for each marriage. Each record has a unique
Autonum field (ID), and also contains two fields IDPartnerMale and
IDPartnerFemale. Both of the latter fields match records in the Person
table via IDPerson.

I have a main form (frmPerson) for displaying a record from the Person
table. This form contains a subform (sfmPartners) which lists in tabular
form certain fields from the Partnerships record (including ID) for which
Person.IDPerson matches either IDPartnerMale or IDPartnerFemale in the
Partnerships table. There may be multiple rows of Partnership displayed if
the Person married more than once.

So far, so good. The subform correctly displays marriage records for the
person displayed in the main form.

In the subform, I have added an Update command button at the end of each
data row. The Click event opens the update form (frmPartnership) and
displays the full Partnerships record whose Update button was clicked in the
subform sfmPartners. At least, that's the theory.

The Update button Click event has the following code:

Private Sub Update_Click()
DoCmd.OpenForm "frmPartnership", , , "Partnerships.ID =
[forms]![sfmPartners]![ID]", acFormEdit
End Sub

If my understanding is correct, this should open frmPartnership with the
Partnerships record matching the ID value of the row in sfmPartners whose
Update button was pressed. However, there appears to be something wrong
with my syntax, because I get prompted to type in the value for
Forms!sfmPartners!ID. If I type in this value, then form frmPartnership
displays with the correct record.

However, if I run sfmPartners as a main form, clicking the Update button
displays the correct update form with the correct value (without prompting
for input). It is only when sfmPartners is opened as a subform of frmPerson
that it fails as described. Can anyone see what I am doing wrong?

One further question -- I have placed the Update button in each row of
Partnerships displayed in sfmPartners. How can I have a single Update
button that opens sfmPartners for the record which is currently SELECTED?
This would seem to be a simpler and more elegant solution.

Thanks in advance.

--
Cheers,
Lyn.
Nov 13 '05 #1
2 2217
Hi Lyn.

First issue is that subforms are not open in their own right, i.e. they are
part of the forms collection. You can refer to them through their parent,
e.g.:

Forms![NameOfYourMainFormHere]![NameOfYourSubfomrControlHere].[Form]![ID]
That is explained in article:
Referring to Controls on a Subform
at:
http://allenbrowne.com/casu-04.html

However, because this code occurs in the context of the form, you don't have
to worry about the parent form. Just concatenate the value from the form
into the string:
DoCmd.OpenForm "frmPartnership", , , "Partnerships.ID = " & Me![ID]

If you would prefer not to have the button on every row, you can place it in
the Form Footer section. Open the subform in design view. From the View
menu, choose Form Header/Footer (not Page Header/Footer). In the Properties
of the form, set the Default View to Continuous Form so the header show up.
The value is automatically interpreted as the value from the currently
selected row.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Lyn" <lh******@ihug.com.au> wrote in message
news:cb**********@lust.ihug.co.nz...
Hi,
I am working on a genealogy project in which I have two tables:

Person -- one record for each person in the family. Each record has a
unique Autonum field (IDPerson).

Partnerships -- one record for each marriage. Each record has a unique
Autonum field (ID), and also contains two fields IDPartnerMale and
IDPartnerFemale. Both of the latter fields match records in the Person
table via IDPerson.

I have a main form (frmPerson) for displaying a record from the Person
table. This form contains a subform (sfmPartners) which lists in tabular
form certain fields from the Partnerships record (including ID) for which
Person.IDPerson matches either IDPartnerMale or IDPartnerFemale in the
Partnerships table. There may be multiple rows of Partnership displayed if the Person married more than once.

So far, so good. The subform correctly displays marriage records for the
person displayed in the main form.

In the subform, I have added an Update command button at the end of each
data row. The Click event opens the update form (frmPartnership) and
displays the full Partnerships record whose Update button was clicked in the subform sfmPartners. At least, that's the theory.

The Update button Click event has the following code:

Private Sub Update_Click()
DoCmd.OpenForm "frmPartnership", , , "Partnerships.ID =
[forms]![sfmPartners]![ID]", acFormEdit
End Sub

If my understanding is correct, this should open frmPartnership with the
Partnerships record matching the ID value of the row in sfmPartners whose
Update button was pressed. However, there appears to be something wrong
with my syntax, because I get prompted to type in the value for
Forms!sfmPartners!ID. If I type in this value, then form frmPartnership
displays with the correct record.

However, if I run sfmPartners as a main form, clicking the Update button
displays the correct update form with the correct value (without prompting
for input). It is only when sfmPartners is opened as a subform of frmPerson that it fails as described. Can anyone see what I am doing wrong?

One further question -- I have placed the Update button in each row of
Partnerships displayed in sfmPartners. How can I have a single Update
button that opens sfmPartners for the record which is currently SELECTED?
This would seem to be a simpler and more elegant solution.

Thanks in advance.

--
Cheers,
Lyn.

Nov 13 '05 #2
Lyn
Allen, thanks for your prompt reply. I knew it was something simple. I had
tried various formats including "Me!ID". The only problem was that I
included the whole thing inside the quotes instead of concatenating the
control reference outside the quotes. It works now. Many thanks.

I will check out your article and also using the form footer.

Thanks again.
--
Cheers,
Lyn.

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40***********************@per-qv1-newsreader-01.iinet.net.au...
Hi Lyn.

First issue is that subforms are not open in their own right, i.e. they are part of the forms collection. You can refer to them through their parent,
e.g.:

Forms![NameOfYourMainFormHere]![NameOfYourSubfomrControlHere].[Form]![ID]
That is explained in article:
Referring to Controls on a Subform
at:
http://allenbrowne.com/casu-04.html

However, because this code occurs in the context of the form, you don't have to worry about the parent form. Just concatenate the value from the form
into the string:
DoCmd.OpenForm "frmPartnership", , , "Partnerships.ID = " & Me![ID]

If you would prefer not to have the button on every row, you can place it in the Form Footer section. Open the subform in design view. From the View
menu, choose Form Header/Footer (not Page Header/Footer). In the Properties of the form, set the Default View to Continuous Form so the header show up. The value is automatically interpreted as the value from the currently
selected row.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Lyn" <lh******@ihug.com.au> wrote in message
news:cb**********@lust.ihug.co.nz...
Hi,
I am working on a genealogy project in which I have two tables:

Person -- one record for each person in the family. Each record has a
unique Autonum field (IDPerson).

Partnerships -- one record for each marriage. Each record has a unique
Autonum field (ID), and also contains two fields IDPartnerMale and
IDPartnerFemale. Both of the latter fields match records in the Person
table via IDPerson.

I have a main form (frmPerson) for displaying a record from the Person
table. This form contains a subform (sfmPartners) which lists in tabular form certain fields from the Partnerships record (including ID) for which Person.IDPerson matches either IDPartnerMale or IDPartnerFemale in the
Partnerships table. There may be multiple rows of Partnership displayed

if
the Person married more than once.

So far, so good. The subform correctly displays marriage records for the
person displayed in the main form.

In the subform, I have added an Update command button at the end of each
data row. The Click event opens the update form (frmPartnership) and
displays the full Partnerships record whose Update button was clicked in

the
subform sfmPartners. At least, that's the theory.

The Update button Click event has the following code:

Private Sub Update_Click()
DoCmd.OpenForm "frmPartnership", , , "Partnerships.ID =
[forms]![sfmPartners]![ID]", acFormEdit
End Sub

If my understanding is correct, this should open frmPartnership with the
Partnerships record matching the ID value of the row in sfmPartners whose Update button was pressed. However, there appears to be something wrong
with my syntax, because I get prompted to type in the value for
Forms!sfmPartners!ID. If I type in this value, then form frmPartnership
displays with the correct record.

However, if I run sfmPartners as a main form, clicking the Update button
displays the correct update form with the correct value (without prompting for input). It is only when sfmPartners is opened as a subform of

frmPerson
that it fails as described. Can anyone see what I am doing wrong?

One further question -- I have placed the Update button in each row of
Partnerships displayed in sfmPartners. How can I have a single Update
button that opens sfmPartners for the record which is currently SELECTED? This would seem to be a simpler and more elegant solution.

Thanks in advance.

--
Cheers,
Lyn.


Nov 13 '05 #3

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

Similar topics

0
by: Thompson Yip | last post by:
From time to time, I randomly receive "Can't updated, Currently locked" error 3218 or 3246 from the following code in one of my form with pessimistic lock for 70 users environment. Any problem with...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
0
by: melanieab | last post by:
Hi, I can't begin to understand this one. I have a form with a tabcontrol. When I first enter one of the pages (whether by tabbing or opening the form), I say to focus on a button. It does focus...
4
by: MrL8Knight | last post by:
Hello, I am trying to build a simple php form based shopping cart using a cookie with arrays. I need to use 1 cookie because each order will have over 20 items. With that said, I realize I need to...
2
by: Mux | last post by:
I am facing the following problem while exporting data to Word. The current implementation is as described below: I have a JSP file which has a link that enables you to export the data to Word....
1
by: robertmeyer1 | last post by:
Hey, I am having a problem with opening some forms. I have several forms. The forms are based off the same table, tblClient. Each form has a sbf inserted into it. These sbf’s are each based...
2
by: Brian K. | last post by:
I've read several posts on this problem, since it's happening to me right now. Can't seem to get rid of this. Using A2K2 on a large XP network. PC front ends linked to a backend on a shared...
2
by: shadowman | last post by:
So here's the situation: I need to write a PHP script which accepts form submissions using all methods (GET and POST) and all content types (application/x-www-form-url-encoded and...
0
by: sjickells | last post by:
Hi I am having a problem using asp:TextBox's in a transparent table. I have a background image on the page and a table in the middle of the page. I have set the background colour of the table...
1
by: KavithaSing | last post by:
Hi everyone, In our website we have an option ‘official login’ for users to login and send information through the site. We face the following problem while loggin in. We use the following...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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.