Solved

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

Posted on 2004-08-31
8
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 500 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

710 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