Link to home
Start Free TrialLog in
Avatar of ExpertPro
ExpertPro

asked on

How to get value of two combobox(s) into textbox in datasheet subform.

Hi Every one,

I have datasheet subform, which have 4 fields.

CustomerId
OrderId
Product

CONumber

For some reasons I  have to store a CONumber which is actuall the combination of customerid and orderid. let see

CustomerId = 100
OrderId = 5001

so CONumber = 1005001

how should I get CONumber in datasheet subform at save time?
I Set the control source property of Textbox to CONumber Field, and update it with afterupdate event of Product (combobox) but then Value won't store in field. If I try to do it before update event  There is a error because of both combobox(s) are empty at that point.


so whats the best way to get the way... of both after its been update but not yet store in the underlying table.

Thanking you in advance....

permood
ASKER CERTIFIED SOLUTION
Avatar of shanesuebsahakarn
shanesuebsahakarn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rey Obrero (Capricorn1)
in the after update event of the combo box

  Me.TextBox=Me.ComboBox.Column(0) & Me.ComboBOx.Column(1)
Avatar of Nestorio
Nestorio

Is the field in the form bound to the table?
oops, sorry i misread that there are two combo boxes
In the properties for the CONumber (design view), on the data tab, in the Source Property place the following:

=[CustomerID] & [OrderID]

If you want to do it with code, you can use the Enter Event of the CONumber, or you could use the FORM property OnCurrent.

Is the order of entry CustomerID then OrderID?

If you mean "save" time, and not "same" time -- you can place the code in the beforeUpdate Event of the FORM.

Let me see the code you are using.

Leslyn :)
Avatar of ExpertPro

ASKER

Thanks every body for your help and time.
shanesuebsahakarn:
I know this is not betterway to store information. but the reason this because:-

Let me explain you little bit might you will come up with better idea.

Each Order include predefined some product automatically and then on top of that customer could add some more products.

   OrderID     Oder
      100      Delux Package 100

now delux package aready have two things which part of products
                     1 Air Ticket
                     1 Room
now this order can have additional products

                     1 Rental Car

 I have only one table for products

same products are getting use in Package table
and then in orders details, then I do the union.

and try make like

Customer

orders
                   
Oder Details

I dont' know if i am able to explain it well or not.


                           
The code I posted for you in the first comment should work (the one with the Me.Dirty line). The value should store in the field so long as you set the textbox's value correctly. If you have a problem,post the code you are currently using to try and save the info.
Thank you everybody!

Specially shanesuebsahakarn for quick and wondefull answer!

Regards,

permood