Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-08-31
8
Medium Priority
?
301 Views
Last Modified: 2008-03-10
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
0
Comment
Question by:ExpertPro
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 2000 total points
ID: 11944479
Simplest way would be to run this in the OnClose event of the (main) form:

CurrentDb.Execute "UPDATE MyTable SET CONumber=[CustomerID] & [OrderID]"

Alternatively, put code in the AfterUpdate event of both the CustomerID and OrderID text boxes like so:

Me!txtCONumber=Me!txtCustomerID & Me!txtOrderID
Me.Dirty = False 'Saves the record to store the information in the underlying table

You should not be storing information like this in the table though - because it is calculated, you should just write a query that returns the information in a calculated field and use that instead.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 11944481
in the after update event of the combo box

  Me.TextBox=Me.ComboBox.Column(0) & Me.ComboBOx.Column(1)
0
 
LVL 16

Expert Comment

by:Nestorio
ID: 11944503
Is the field in the form bound to the table?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 11944507
oops, sorry i misread that there are two combo boxes
0
 
LVL 4

Expert Comment

by:leslynf
ID: 11944542
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 :)
0
 
LVL 1

Author Comment

by:ExpertPro
ID: 11944769
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.


                           
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 11944808
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.
0
 
LVL 1

Author Comment

by:ExpertPro
ID: 12009093
Thank you everybody!

Specially shanesuebsahakarn for quick and wondefull answer!

Regards,

permood
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question