Passing all values from a subform to another subform

Sym

Registered User.
Local time
Today, 10:09
Joined
Feb 21, 2015
Messages
40
I know how to use openargs to pass values between forms but im not sure how to go about passing all the values from one subform to another.

To be specific I have an order form (frmCustomerOrders) that has fields like CustomerName, EmployeeName, OrderDate and so forth, the subform (frmCustomerOrdersSubform) contains information on the Products the customer is ordering which usually has multiple records with fields like ProductName, PartNumber, Quantity and ItemNumber. I want to pass the values from the CustomerOrdersSubform form to another subform (TransferSubform) My initial thought was to use something like the openform command through openargs but im not sure if that will work or if there is another method I should use.

thanks in advance
 
I want to pass the values from the CustomerOrdersSubform form to another subform (TransferSubform)
I wouldn't pass ALL the values. The data is stored in a table, so pass a key that links to that data, and use that key to requery the data from the source table. Presumably this would be the OrderID.
 
im not exactly sure what you mean. the key/fk link to the form I want the data to transfer is to different tables so im not sure how that would work, could you expand on what your describing and how I would requery data from a different table than the one the form is linked to?
 
how I would requery data from a different table than the one the form is linked to
1) Open a recordset of exactly the data you need, or 2) create a reference to FormA on FormB. So if FormA is based on TableA, and FormB on TableB, then to work with TableA data on FormB you could use code like . . .
Code:
sub cmdShowFormAData_Click()
[COLOR="Green"]   'this code is on FormB, but displays data from FormA[/COLOR]
   MsgBox Forms("FormA").SomeTableAField
end sub
Does that make sense? You don't have to push the data from the source to the destination, just get the destination to pull it from the source.

I guess there is also 3) call a public function on the other form, like . . .
Code:
Public Sub DoSomething(WithData As String)
[COLOR="Green"]   'this code is Public, and on FormB[/COLOR]
   MsgBox WithData
End Sub

Private Sub cmdDoSomethingOnFormB_Click()
[COLOR="Green"]   'this code in on FormA, passes data to FormB, and runs code there too[/COLOR]
   Forms!FormB.DoSomething(Me.DataFromFormA)
End Sub

... and there are other options using Events and WithEvents variables, but that is harder.

Hope this helps,
 
Sorry MarkK but im a total noob when it comes to this. Im still a bit confused about what you are suggesting. Currently I have a button on Form A that opens Form B and passes the Parent values of the form to Form B using Openargs. From what I understand from your posts to pass the subform data in form A to the subform data in form B I should just get that form to pull the data from the source rather than actually copying it like I did with the parent data. I have tried to take your advice and follow that but im missing something as everything I try fails to work. I have added some comments to your earlier post to try and narrow down where im getting confused.

1) Open a recordset of exactly the data you need, Im not sure what you mean by this, do you mean just open form A, open that table or something else entirely?

or 2) create a reference to FormA on FormB. do you mean create a relationship between them?

So if FormA is based on TableA, and FormB on TableB, then to work with TableA data on FormB you could use code like . . .
Code:
sub cmdShowFormAData_Click()
[COLOR=green]  'this code is on FormB, but displays data from FormA[/COLOR]
   MsgBox Forms("FormA").SomeTableAField
end sub
Does that make sense? You don't have to push the data from the source to the destination, just get the destination to pull it from the source. I get what this code does, it will show the value of the data of that field in a message box but im not sure what the point of that is other than to remind me what that value is...

I guess there is also 3) call a public function on the other form, like . . .
Code:
Public Sub DoSomething(WithData As String)
[COLOR=green]  'this code is Public, and on FormB[/COLOR]
   MsgBox WithData
End Sub

Private Sub cmdDoSomethingOnFormB_Click()
[COLOR=green]  'this code in on FormA, passes data to FormB, and runs code there too[/COLOR]
   Forms!FormB.DoSomething(Me.DataFromFormA)
End Sub
... and there are other options using Events and WithEvents variables, but that is harder.

Hope this helps,

I think I know what your getting at but im having trouble getting the form to pull the data from that table correctly.
 
I want to pass the values
I think we need to back up. I think your original post is not very specific, and I offered you some vague ways you might do what I guessed you wanted, and then you made general comments on my vague guesses on your lack of specificity.

What, exactly, are you trying to do? Why "pass values" at all? If I know the precise problem you need to solve, then I can make a more precise recommendation as to how I would go about it.

Does that make sense?
 
okay I will restart including specifics, its possible that im going about this totally wrong.

The database I built is an inventory/order tracking database. in this case The first form im working with is a "sales Order" form, the parent part of this form contains information on the customer like their name, company name, date and stuff like that which is stored in the "tblsalesorders" table. the subform contains information on the parts they order like part Numbers, Part names, quantities and so on, (usually, there is more than one part ordered so there is multiple records in the subform) this data is stored in the "tblsalesorderdetail" table.

The second form is a "Transfer" form, which is build similar to the sales order form with the customer data in the parent and the part information in the subform. the reason for this is sometimes the sales order is installed by our employees who have their own trucks that in turn have their own inventories, we track what is in each truck as well as what we have in our stock room so when an order is to be installed instead of shipped the order needs to be transferred to that truck.

As it is Right now you have to fill out the sales order form and then completely fill out the transfer form exactly as you did the sales order form. its a pain and a time sink to re-enter the same data into another form so what i would like to create is something that basically copys the data in the sales order form to the transfer form.

i can do that with the parent data with Openargs but i don't know how to do the subform part.

does that clear up what im trying to do?
 
As it is Right now you have to fill out the sales order form and then completely fill out the transfer form exactly as you did the sales order form.
What I believe based on this description, is that you have duplicated data in tables that should not be duplicated. For instance, lets say you fill out an order. After that, that order might get shipped, or might be placed in a truck, so create a table into which you record where the order goes, not a table that necessitates that you re-enter existing data. Create a table that is the possible list of destinations, and attach that data to the order so you don't have to re-enter order. Where the order goes it like a status.

Does that make sense/sound right?
 
I hear what your saying and initially I was going to build it that way but sometimes we transfer items to the trucks that arnt on sales orders like consumables for instance that we don't put on sales orders but in thinking of this I may modify they way the sales orders work to incorporate what you said while also keeping the transfer form for those times we transfer items that arnt on sales orders.
 
sometimes we transfer items to the trucks that arnt on sales orders like consumables for instance
Then you should start a new order for that specific purpose. I just want to stress that duplicating data is a huge risk of the greatest possible failure as a programmer, which is that you write a system that might be in conflict with itself. That's like answering Yes AND No to the same question, which should be embarrassing, and that will happen if you store the same data in two places. Someone, one day, will edit one of the copies, and then which copy is true???

I'm joking a bit, but the point is that if you find yourself duplicating anything, then you should stop, back up a little, and explore other options. Probably there is a better way. And then you don't have to do what you originally asked about, because moving ALL the values, in addition to being risky, is also a headache.

Hope this helps,
 

Users who are viewing this thread

Back
Top Bottom