473,382 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

combobox

hello
i am pretty new at using access and having a little trouble
i have a combobox containing a list of parts.
the user slects a part from the list, i then want the part price to
show in a text box(done this), i also want the part number to appear
in anoter text box(cant do this)
the code below works great for one text box but i cant get it to
display the second value.

Any ideas where i going wrong?
Private Sub Component_Change()

If Not IsNull(Component.Column(1)) Then
[Piece Price] = Component.Column(1)

End Sub

thanks in advance
kevin
Nov 13 '05 #1
2 1242
The way I would solve this would be

1. change the code to :
debug.print component.column(0); component.column(1)
make sure this is the right syntax and the right column
2. add a variable:
Dim S as string
3. change the code from 1 to
S = component.column(1)
4. see if you can change the piece price by adding the following code
me.controls("piece price") = "hello world"
5. if all of the above works then try this:
me.controls("piece price") = S

Hope this helps

Nicolaas
"Kevin Carter" <kc******@ford.com> wrote in message
news:2a**************************@posting.google.c om...
hello
i am pretty new at using access and having a little trouble
i have a combobox containing a list of parts.
the user slects a part from the list, i then want the part price to
show in a text box(done this), i also want the part number to appear
in anoter text box(cant do this)
the code below works great for one text box but i cant get it to
display the second value.

Any ideas where i going wrong?
Private Sub Component_Change()

If Not IsNull(Component.Column(1)) Then
[Piece Price] = Component.Column(1)

End Sub

thanks in advance
kevin

---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004
Nov 13 '05 #2
Hi Kevin

As Nicolaas has said, you can fill other fields by using a multi-column
combo-box to supply the values.
The Column value of a combo-box is "Zero-based" (i.e. 0,1,2,3...) with 0
being the leftmost column.
I also think that you'll want to use the AfterUpdate event, rather than the
OnChange event

I just so happen to have a relevant code sample from my parts inventory app
to illustrate: :-)
(This code is from a subform named "sbfTransactions" which is on a main form
called "frmVehicleRepairs")
I use this combo-box to select a partnumber, record the transaction, as well
as offer the user a choice of pricing methods...

i.e.
Cost + x%
or
Retail - x%
------------------------------------
**************************************
Private Sub cboPartNumber_AfterUpdate()

Dim ctl As Control
Set ctl = Me.cboPartNumber

With ctl
' Column(0) contains "PartID" ... which we don't need here.
Me![PartNumber] = .Column(1)
Me![Line] = .Column(2)
Me![Description] = .Column(3)
Me![PartRetail] = Nz(.Column(4), 0)
Me![PartCost] = Nz(.Column(5), 0)
Me![PartCore] = Nz(.Column(6), 0)
Me![SupplierID] = .Column(7)

End With

If IsLoaded("frmVehicleRepairs") Then 'I use this subform elsewhere. This
code is only used with "frmVehicleRepairs" to record a parts sale.
Dim MyPrice
Dim PlusOrMinus
Dim MyPcnt
Dim BasePrice

MyPrice = Parent![cboSheet] 'A value-list combo-box contain the values
"Cost" and "Retail"
PlusOrMinus = Parent![PlusMinus] & "1" 'A value-list combo-box contain
the values "+" and "-" ...
' this variable returns either "+1" or "-1" for the purposes of
calculation.

MyPcnt = Parent![Pcnt] ' a textbox that the user enters a percentage
value into... includes a simple method to correct invalid entries... see
below
BasePrice = CCur(Me.Controls("Part" & MyPrice)) ' ie "PartCost" or
"PartRetail"
Me![SellPrice] = BasePrice + (BasePrice * (PlusOrMinus * MyPcnt))
Me.TransType = "Parts Sale"
End If

Me.TransQty.SetFocus

Set ctl = Nothing

End Sub
**************************************
The code below is on the main form ("frmVehicleRepairs")

Private Sub Pcnt_AfterUpdate()
' corrects entries from "7" to "0.07" IF they are entered that way.
If Me!Pcnt > 1 Then
Me!Pcnt = Me!Pcnt / 100
End If

End Sub
**************************************

--
HTH,
Don
=============================
Use My*****@Telus.Net for e-mail
Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.

Do Until SinksIn = True
File/Save, <slam fingers in desk drawer>
Loop

================================

"Kevin Carter" <kc******@ford.com> wrote in message
news:2a**************************@posting.google.c om...
hello
i am pretty new at using access and having a little trouble
i have a combobox containing a list of parts.
the user slects a part from the list, i then want the part price to
show in a text box(done this), i also want the part number to appear
in anoter text box(cant do this)
the code below works great for one text box but i cant get it to
display the second value.

Any ideas where i going wrong?
Private Sub Component_Change()

If Not IsNull(Component.Column(1)) Then
[Piece Price] = Component.Column(1)

End Sub

thanks in advance
kevin

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Mr. B | last post by:
Here's the situation... You've a combobox with Items already added. Say they look like this (or even lines of text): 10-00-232 10-00-256 10-01-006 10-01-213 10-02-200
7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
8
by: Zlatko Matię | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: anonymous | last post by:
I've been trying to put a them, please help me out. Here's the major parts of my code: public Form1() { DataSet myDataSet = new DataSet("myDataSet"); DataTable testTable = new...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
2
by: Don | last post by:
I've looked high and low for some code that will allow me to have a combobox with a flat borderstyle. I found a few examples, but nothing that was really usable for me. I had the following...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
1
by: polocar | last post by:
Ciao a tutti, leggendo qua e lą per il forum ho scoperto che non sono l'unico ad avere questo problema. Se si inserisce un controllo ComboBox in un form di C#, non č possibile impostare la sua...
5
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.