473,385 Members | 2,269 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,385 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 8786
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 want to enter more than one records. TIA Sigurd
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 as each user adds records. The users also need...
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 when leaving it). It seems to be impossible to...
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 for the subform control is, of course,...
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 approach to do the following in A2K: SET UP: I have...
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: Private Sub btnClose_Click() '4/16/06 new code that...
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 from a table: SELECT DISTINCTROW Transcript.NCID,...
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 the records(s) in the subform and tab to another...
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 Access 2002 and have a single form bound to a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.