472,338 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Updating subform records after closing popup form

Hi,

I have a 'main' form called frmIssues which has a subform control
(named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs.
A control button on the main form opens a pop-up form which allows me
to edit the record in the subform. What I want to happen is for
subform with the new edits to be updated on the main form when I close
the popup. I'm sure this is a very small bit of code in the the 'On
close' event for the popup form, but I can't work it out. Any
guidance please!

Thanks in advance,

MacBane

Jan 31 '07 #1
4 8638
Macbane wrote:
Hi,

I have a 'main' form called frmIssues which has a subform control
(named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs.
A control button on the main form opens a pop-up form which allows me
to edit the record in the subform. What I want to happen is for
subform with the new edits to be updated on the main form when I close
the popup. I'm sure this is a very small bit of code in the the 'On
close' event for the popup form, but I can't work it out. Any
guidance please!

Thanks in advance,

MacBane
Could you provide some more information? You have a
form/subform/subsubform. The popup is to update which suform; sub or
subsub?

Forms can be bound (a table or query) or unbound (no table or query).
In the main form's forms are they bound and the popup unbound? If both
the form and popup are bound, the results should update correctly
without going thru any jumps thru hoops.
Jan 31 '07 #2
On Jan 31, 5:18 pm, salad <o...@vinegar.comwrote:
Macbane wrote:
Hi,
I have a 'main' form called frmIssues which has a subform control
(named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs.
A control button on the main form opens a pop-up form which allows me
to edit the record in the subform. What I want to happen is for
subform with the new edits to be updated on the main form when I close
the popup. I'm sure this is a very small bit of code in the the 'On
close' event for the popup form, but I can't work it out. Any
guidance please!
Thanks in advance,
MacBane

Could you provide some more information? You have a
form/subform/subsubform. The popup is to update which suform; sub or
subsub?

Forms can be bound (a table or query) or unbound (no table or query).
In the main form's forms are they bound and the popup unbound? If both
the form and popup are bound, the results should update correctly
without going thru any jumps thru hoops.- Hide quoted text -

- Show quoted text -
Hi,

OK, probably over complicated it and under-explained it. Right, I
have a main form frmIssus that has 1 subform called frmDrugs which is
linked using the ID field IssuesID (Mentioning the subform control
might have suggested that the subform has a subform but it doesn't).
Both forms are bound to SQL statements based on a combination of the
linked tables tblIssues, tblDrugs and tblLinkIssuesDrugs (Many-to-many
relationship) Fairly straight forward so far until I got a bit fancy
and just didn't like the look of the subform. What I did was to
change the format of the subform so that it just displays the subform
field (Drugname) but you cannot edit or add (changed combo boxes to
text boxes, disallowed Edits and Additions) . To edit or add, I put a
button control on the main form beside the subform which opens a copy
of the subform (frmDrugsEdit) as a popup form. I can then edit or add
new data and I think it looks much better. What I want is a way to
requery the subform imbedded on the main form with the changes made on
the popup when I close the popup. Do I have to requery the whole main
form or can I 'requery' the 'imbedded' subform. I need a bit of code
in the On-close event for the popup form. Any ideas? God help me if
this doesn't make sense.

Thanks,

Macbane

Feb 1 '07 #3
Macbane wrote:
On Jan 31, 5:18 pm, salad <o...@vinegar.comwrote:
>>Macbane wrote:
>>>Hi,
>>>I have a 'main' form called frmIssues which has a subform control
(named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs.
A control button on the main form opens a pop-up form which allows me
to edit the record in the subform. What I want to happen is for
subform with the new edits to be updated on the main form when I close
the popup. I'm sure this is a very small bit of code in the the 'On
close' event for the popup form, but I can't work it out. Any
guidance please!
>>>Thanks in advance,
>>>MacBane

Could you provide some more information? You have a
form/subform/subsubform. The popup is to update which suform; sub or
subsub?

Forms can be bound (a table or query) or unbound (no table or query).
In the main form's forms are they bound and the popup unbound? If both
the form and popup are bound, the results should update correctly
without going thru any jumps thru hoops.- Hide quoted text -

- Show quoted text -


Hi,

OK, probably over complicated it and under-explained it. Right, I
have a main form frmIssus that has 1 subform called frmDrugs which is
linked using the ID field IssuesID (Mentioning the subform control
might have suggested that the subform has a subform but it doesn't).
Both forms are bound to SQL statements based on a combination of the
linked tables tblIssues, tblDrugs and tblLinkIssuesDrugs (Many-to-many
relationship) Fairly straight forward so far until I got a bit fancy
and just didn't like the look of the subform. What I did was to
change the format of the subform so that it just displays the subform
field (Drugname) but you cannot edit or add (changed combo boxes to
text boxes, disallowed Edits and Additions) . To edit or add, I put a
button control on the main form beside the subform which opens a copy
of the subform (frmDrugsEdit) as a popup form. I can then edit or add
new data and I think it looks much better. What I want is a way to
requery the subform imbedded on the main form with the changes made on
the popup when I close the popup. Do I have to requery the whole main
form or can I 'requery' the 'imbedded' subform. I need a bit of code
in the On-close event for the popup form. Any ideas? God help me if
this doesn't make sense.

Thanks,

Macbane
I'm not sure if my solution will help, maybe you can glean something
from it that will help your situation.

If I had a form/subform that was bound (which I believe is your case)
and I called another form with something like
Docmd.Openform "UpdateIt",,,"ID = " & Me.Subform!ID,acdialog
I'd expect the dialog form to open to my current record and if I
modifyied/saved the record in the dialog the data would be updated on
the main subform.

You are right. You may have to save it and requery. In your
declarations you might declare a variable to hold your ID number of the
record you are editting.
Dim lngID As Long

In the BeforeUpdate event of the dialog you might enter
lngID = Me.ID

And in the OnClose event you might enter
Dim rst As DAO.Recordset

'requery the subform
Forms!MainForm!SubForm.Form.Requery

'now find the record you added/modified
set rst = Forms!MainForm!SubForm.Form.RecordsetClone
rst.findfirst "ID = " & lngID

If not rst.nomatch then
'it was found. move to it.
Forms!MainForm!SubForm.Form.BookMark = rst.Bookmark
Endif
rst.close
set rst = nothing

Hope this helps.
Feb 1 '07 #4
On Feb 1, 3:19 pm, salad <o...@vinegar.comwrote:
Macbane wrote:
On Jan 31, 5:18 pm, salad <o...@vinegar.comwrote:
>Macbane wrote:
>>Hi,
>>I have a 'main' form called frmIssues which has a subform control
(named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs.
A control button on the main form opens a pop-up form which allows me
to edit the record in the subform. What I want to happen is for
subform with the new edits to be updated on the main form when I close
the popup. I'm sure this is a very small bit of code in the the 'On
close' event for the popup form, but I can't work it out. Any
guidance please!
>>Thanks in advance,
>>MacBane
>Could you provide some more information? You have a
form/subform/subsubform. The popup is to update which suform; sub or
subsub?
>Forms can be bound (a table or query) or unbound (no table or query).
In the main form's forms are they bound and the popup unbound? If both
the form and popup are bound, the results should update correctly
without going thru any jumps thru hoops.- Hide quoted text -
>- Show quoted text -
Hi,
OK, probably over complicated it and under-explained it. Right, I
have a main form frmIssus that has 1 subform called frmDrugs which is
linked using the ID field IssuesID (Mentioning the subform control
might have suggested that the subform has a subform but it doesn't).
Both forms are bound to SQL statements based on a combination of the
linked tables tblIssues, tblDrugs and tblLinkIssuesDrugs (Many-to-many
relationship) Fairly straight forward so far until I got a bit fancy
and just didn't like the look of the subform. What I did was to
change the format of the subform so that it just displays the subform
field (Drugname) but you cannot edit or add (changed combo boxes to
text boxes, disallowed Edits and Additions) . To edit or add, I put a
button control on the main form beside the subform which opens a copy
of the subform (frmDrugsEdit) as a popup form. I can then edit or add
new data and I think it looks much better. What I want is a way to
requery the subform imbedded on the main form with the changes made on
the popup when I close the popup. Do I have to requery the whole main
form or can I 'requery' the 'imbedded' subform. I need a bit of code
in the On-close event for the popup form. Any ideas? God help me if
this doesn't make sense.
Thanks,
Macbane

I'm not sure if my solution will help, maybe you can glean something
from it that will help your situation.

If I had a form/subform that was bound (which I believe is your case)
and I called another form with something like
Docmd.Openform "UpdateIt",,,"ID = " & Me.Subform!ID,acdialog
I'd expect the dialog form to open to my current record and if I
modifyied/saved the record in the dialog the data would be updated on
the main subform.

You are right. You may have to save it and requery. In your
declarations you might declare a variable to hold your ID number of the
record you are editting.
Dim lngID As Long

In the BeforeUpdate event of the dialog you might enter
lngID = Me.ID

And in the OnClose event you might enter
Dim rst As DAO.Recordset

'requery the subform
Forms!MainForm!SubForm.Form.Requery

'now find the record you added/modified
set rst = Forms!MainForm!SubForm.Form.RecordsetClone
rst.findfirst "ID = " & lngID

If not rst.nomatch then
'it was found. move to it.
Forms!MainForm!SubForm.Form.BookMark = rst.Bookmark
Endif
rst.close
set rst = nothing

Hope this helps.- Hide quoted text -

- Show quoted text -
Thanks Salad. I had a problem with referring to my subforms but your
advice & instructions on mvps.org (http://mvps.org/access/forms/
frm0031.htm) got me sorted. Highly recommeded reading. Thanks again

Macbane

PS Best of luck flogging your new app!

Feb 2 '07 #5

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

Similar topics

1
by: Sigurd Bruteig | last post by:
Hi In some cases I use a popup form to enter data in a subform. The problem is to select a new record in the subform from the popup form, when I...
3
by: CSDunn | last post by:
Hello, I have an Access 2000 Project in which the data comes from a SQL Server 2000 database, and multiple users need to be able to see new records...
3
by: Uwe Range | last post by:
Hi to all, I am displaying a list of records in a subform which is embedded in a popup main form (in order to ensure that users close the form...
12
by: MLH | last post by:
I have created two forms: frmBrowseNegsMainform and frmBrowseNegsSubform. I put a subform control on the first of these. The SourceObject property...
1
by: phaddock4 | last post by:
Being fairly inexperienced at Access 2000, i've been reading many posts here for the last several days, and testing myself to find the best...
4
by: tlyczko | last post by:
I have been looking on the NGs and I found this code to show if a subform has no records. I have this code in the MAIN form OnClose event: ...
3
by: stuart.medlin | last post by:
I have an Access 97 application that has a basic form (Transcript) and subform. The subform has a query as a recordsource that returns records...
0
by: jwbird | last post by:
I have a main form with multiple Subforms that are all displaying Datasheet information related to the Main form record. When I make changes/adds to...
1
by: Ands | last post by:
Hi At the risk of showing my ignorance I wondering if anyone can advise me how best to update records behind a form. Here's the problem I am using...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.