Solved

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

Posted on 2004-08-31
8
286 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 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

820 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