Solved

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

Posted on 2004-08-31
8
281 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 119

Expert Comment

by:Rey Obrero
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
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 11944507
oops, sorry i misread that there are two combo boxes
0
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.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now