473,387 Members | 1,515 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,387 software developers and data experts.

ComboBox - ChangeEvent - update Field

I have a tabular form that has a combo box on it that is reading from
a database. When that combobox changes, I want it to lookup a database
record to get a value and set the value into another text field on the
same form and record. Everything works fine except for that the change
event updates everything on the form not just the current recordset
that I am in and where the change event was started. Here is my code
any help is appreciated. I am small business owner and doing this for
a management report so my gentle with my coding approach.

Private Sub activity_type_Change()

Dim cnn As ADODB.Connection
Dim strSQL As String
Dim rs As ADODB.Recordset
Set cnn = CurrentProject.Connection

strSQL = "SELECT activity_point FROM activitytype WHERE
activitytype_id = " + Me.activity_type

Set rs = cnn.Execute(strSQL)

Me.Text13.Value = rs(0).Value

End Sub
Nov 13 '05 #1
1 4183
The change event fires on each keystroke, so it is not the one where you
want this code. Try the code in the AfterUpdate event... that means a
selection has been made by the user.

I don't understand what you mean by "updating everything in the form". The
code you show seems to me to update just the value currently displayed in
Text13 (though if I am right in my recollection, it would update it multiple
times, some with only partial data entered in the Combo).

Are you using a continuous forms view Form with multiple records displayed
and all the records are updated? If so, is Text13 an unbound Text Box? If
so, then that's the way unbound controls work in continuous forms view:
there is really only one detail section, and the other records that are
shown are just painted on the screen if they are bound. But an unbound
control, is changed in every visible copy whenever it is changed in the
currently selected record.

Larry Linson
Microsoft Access MVP

"Andy Frank" <an********@udig.com> wrote in message
news:cb**************************@posting.google.c om...
I have a tabular form that has a combo box on it that is reading from
a database. When that combobox changes, I want it to lookup a database
record to get a value and set the value into another text field on the
same form and record. Everything works fine except for that the change
event updates everything on the form not just the current recordset
that I am in and where the change event was started. Here is my code
any help is appreciated. I am small business owner and doing this for
a management report so my gentle with my coding approach.

Private Sub activity_type_Change()

Dim cnn As ADODB.Connection
Dim strSQL As String
Dim rs As ADODB.Recordset
Set cnn = CurrentProject.Connection

strSQL = "SELECT activity_point FROM activitytype WHERE
activitytype_id = " + Me.activity_type

Set rs = cnn.Execute(strSQL)

Me.Text13.Value = rs(0).Value

End Sub

Nov 13 '05 #2

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

Similar topics

3
by: Paul Fairless | last post by:
Customers table - contains Columns: CustID, Surname, Forename, TtlID Titles table - contains Columns: TtlID, Title TtlID is a Foreign Key in the Customers table. I have a Form frmCustomers...
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...
7
by: Simon Verona | last post by:
I posted this in dotnet.languages.vb.controls but thought I'd post here as well.. I have a combobox that is bound to a dataview generated from a dataset. The dataset has a single table...
0
by: bcreighton | last post by:
I have created a bound subform on an unbound masterform linked together with a common field (A store's identification number) using an unbound combobox on the masterform and an invisible field on...
5
by: Gil | last post by:
Is there a way to tell if a combbox is in dropdown mode. I tried and if statement combobox.dropdown = true but i get an error. dropwndown function doesnt store if its true or false what i am...
10
by: AA Arens | last post by:
I have two tables, one consists of company info like name and phone number. Another table where I have to fill in the contact persons. Part of the form is to choose the company he works for (From...
0
by: Frnak McKenney | last post by:
Can I use a bound ComboBox for both browsing and editing? I'm working on a small, standalone database application using Visual C#.NET 2003 and an Access data file. In order to keep the number...
4
by: EManning | last post by:
I have a combobox whose rowsource is a union query. This query displays a person's name in "lastname, firstname" format and in "firstname lastname" format. The query results look like this: ...
1
by: Rosie | last post by:
I have a main form with header info w/ 'tHeader' as the control source. I have a subform with 'tDetail' as a control source. They're strung together by a field named MA_ID. This works...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.