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

Updating parent form from child form

Hi,

First, the background info:

I have a parent form, New_Jobcard that contains a combo-box to select Cust_ID. The combobox shows customers sorted by name and address, like this:

Cust_ID V Cust_Name Cust_Addr Cust_Phone

"Cust_ID V" is the combobox.
Cust_Name... Phone are un-editable fields, from the Customers table, and the combobox shows these as columns so you can use it to choose the right Cust_ID from the name and address details.

This all works fine. I have another combobox, Unit_ID, which displays a list of the customer's previously repaired items for easy selection; when you select a customer, this combobox gets updated and displays the relevant records correctly. It's set up similarly to the Cust_ID field, with uneditable fields to the right which show the details of the selected Unit_ID, lik this:

Unit_ID V Unit_Make Unit_Model Unit_SN

This also works fine.

Now to my problem:

I have now introduced a "New" button for adding new customers: it opens the New_Customer form, so that you can put a new customer's details in, and has a "Close" button which, stuffs the new Cust_ID into the parent form's Cust_ID combo, and then makes the combobox requery. The new Cust_ID appears in the combo ok, and the new customer's details appear in the combo list, but the uneditable ("Cust_Name" etc.) fields don't get updated unless you manually select the new cust ID from the list.

I must be missing something - all I *think* I need to do is tell the combobox that a new *selection* has occurred, rather than stuffing the value directly into it. I just can't figure out how! (Maybe I'm asking the impossible, or maybe I have it all wrong, both are entirely possible).

regards,
-cybervegan
Feb 14 '07 #1
9 6095
NeoPa
32,556 Expert Mod 16PB
To select a Row in a ComboBox from within code, simply set it to the value of the Row. To refer to items on connected forms see (Referring to Items on a Sub-Form).
Feb 14 '07 #2
To select a Row in a ComboBox from within code, simply set it to the value of the Row. To refer to items on connected forms see (Referring to Items on a Sub-Form).
Thanks for your reply, EnoPa. Terminology, as ever, confuses the issue (me not using the right terms!). I'm not using *sub-forms* - I am using separate forms, called by an openform command button (not sure if that matters) on the "parent" form, but the advice on the link you gave seems to be more about sub-forms. I know how to address the elements of the other forms, it's just the problem of triggering the update of the parent form's data when a new record is added via the child form.

Rephrasing my question, I think what I really need to know is how to "simulate" the user selecting an item on the main form's combobox, from the subordinate form's "Close" action button, or informing the combobox control that a new value has been put into it. I'm using the .Requery method on the combo, and that works - the new record is shown in the drop-down list, but you have to select it manually: I want it to be automatically selected.

Thanks again,
-cybervegan
Feb 15 '07 #3
NeoPa
32,556 Expert Mod 16PB
  • The term Parent is not correct for referring to a form which caused another form to be opened (I do understand you though ;)).
  • Any code for a Close button should preferably be handled in the OnClose event of the form. This way, an operator hitting the x at top right, will not cause it to be handled in an inconsistent manner.
  • The link also includes references to unconnected forms as well as to subforms and parent forms (Careful of the term Parent here).
  • Your OnClose event procedure can therefore set a value in the ComboBox of the calling form as well as cause it to .requery.
  • It is good coding practice to handle the possibility of the calling form not being open in your code. You don't want a crash just because the operator closed it by mistake.
Feb 15 '07 #4
Thanks, NeoPa,

I'll give that a try. I was thinking about the possiblity of theuser just exitingthe form with the windows close - that's a great tip, thanks.

The code I have already puts the value into the combobox, and then does a .requery, however, the record is still not *selected*, and thus the table relationships are not "followed" (the informational fields do not update and contain stale data until the user manually selects the new record from the combobox list).

Is therer a way to tell the control that it's selected value has changed, as if the user had selected the new record?

thanks,
-cybervegan
Feb 15 '07 #5
NeoPa
32,556 Expert Mod 16PB
Is there a way to tell the control that it's selected value has changed, as if the user had selected the new record?
If you're asking about a ComboBox then yes.
You assign the new required value to it.
Expand|Select|Wrap|Line Numbers
  1. cboRecord = "New Record Value"
Feb 15 '07 #6
If you're asking about a ComboBox then yes.
You assign the new required value to it.
Expand|Select|Wrap|Line Numbers
  1. cboRecord = "New Record Value"
Yes, as I said, I'm doing exactly that, but it doesn't *select* the record, and it doesn't follow relationships and update the display corresponding fields on the form. That only happens if you manually click on the entry in the drop-down box - the display fields are then updated correctly. Assigning it a value does not have the same effect :-(

I'm looking at doing this a different way - using a procession of selection forms, wizard-style, with the selections ending up on the final form. Not exactly what I had in mind, but...

regards,
-cybervegan
Feb 16 '07 #7
NeoPa
32,556 Expert Mod 16PB
Sorry to hear that.
I guess I haven't used it exactly the way you do before, but I often have to set a default value depending on other selections on a form and that's always worked for me.
Feb 16 '07 #8
I have a solution.

(Ghasp!)

Instead of using bound fields to show the details for the currently selected cust_id, i am now using unbound fields and populating them via dlookup() in the OnClick and OnChange event procs of the combobox and the "New Customer" button. The form's OnLoad procedure clears the values (this is a data entry form).

It's more work, but it does what i want, which is provide user-feedback that the newly entered customer record has been correctly saved and selected.

-cybervegan
Feb 21 '07 #9
NeoPa
32,556 Expert Mod 16PB
Sorry I couldn't help more.
I admit to being a bit confused by your responses - what I understand you to be saying doesn't fit with my understanding of how things work. That could be for any number of reasons though. I'm not fool enough to think I know all there is to know, so there could just be something I'm unaware of.
Personally I'd want to find and fix whatever problem you're having, but that's just not practical in the current circumstances, in the dark as I am (not blaming you for this - just what you get sometimes dealing at second-hand) as to what exactly is going on. In the circumstances you need to go with whatever you can get to work.
Hopefully we can give you a better response time you call on us for help.
Feb 22 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tobias | last post by:
Hi! I had Apache 2.0.47 and PHP 4.3.0 DEV running successfully on a W2k Server. For some reason, I couldn't get PHP to read XML-Attributes with the DOM XML -functions. So I thought, it would be...
1
by: | last post by:
Is there anyway to update a control held on my main form from a child form? I've tried making the control itself public but I still can't seem to access it
2
by: Robert Nurse | last post by:
Hi All, I'm trying to alter the contents of a drop-down (select) list on the parent window from a child window in IE 6. After opening the child window, I set its opener to reference the parent...
2
by: Kenny | last post by:
Hello all, I've made a dataset by using the xsd tool in C#. In the xsd schema, there are a few tables, each has its own primary key. And, I've made relation between them. After all things are...
10
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
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...
14
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these...
3
by: Eddie | last post by:
If FormMain = MDI parent, FormSub = Child parent, I execute FormSub from the menu like this way. FormSub^ sub = gcnew FormSub; sub->MdiParent = this; sub->Show(); This can generate child...
2
by: Jason Wilson | last post by:
I am trying to create a popup window that will give a user the option to lookup a value and return it to a textbox on the parent page. Here is my relevant code: Code on Parent <form...
0
by: kolalakitty | last post by:
Hopefully someone here can help me/point me in the right direction. I've found tons of references towards making relations, creating rows, saving said rows, using datagrids, databinding objects,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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
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...

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.