473,387 Members | 1,585 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.

binding textbox to combo

Anyone with know the best way to do this one?
I have a form that is unbound (i.e. in its properties the form itself
is blank for the datasource). I have a combobox named "cboDBName" and a
textbox named "txtPathName". The combobox has as its datasource the
following:

SELECT [tblDatabases].[DBName] FROM tblDatabases ORDER BY
[tblDatabases].[DBName];

The table is simply a two column one with the database name (column 1)
and the database (path column 2).

I want the database path to appear in the textbox when the combobox
receives its choice. I used the following in the after_update code for
the combobox and this doesn't work:

Private Sub cboDBName_AfterUpdate()
Me.txtPathName = Me.cboDBName.Column(2)
End Sub

'Any ideas? thanks!

Apr 17 '06 #1
9 2564
On 17 Apr 2006 10:56:52 -0700, "Parasyke" <kr************@yahoo.com>
wrote:
Anyone with know the best way to do this one?
I have a form that is unbound (i.e. in its properties the form itself
is blank for the datasource). I have a combobox named "cboDBName" and a
textbox named "txtPathName". The combobox has as its datasource the
following:

SELECT [tblDatabases].[DBName] FROM tblDatabases ORDER BY
[tblDatabases].[DBName];

The table is simply a two column one with the database name (column 1)
and the database (path column 2).

I want the database path to appear in the textbox when the combobox
receives its choice. I used the following in the after_update code for
the combobox and this doesn't work:

Private Sub cboDBName_AfterUpdate()
Me.txtPathName = Me.cboDBName.Column(2)
End Sub


combo box columns are zero based. Try .Column(1)

Jim
Apr 17 '06 #2
I looked at the properties for my combobox and the bound column is set
to 1 which gives me the correct database name, but I changed it to 0
and got an error. changing the Column(2) in the textbox to Column(1)
didn't change anything.

Apr 17 '06 #3
And select both the db name AND the path in your SELECT statement.

Apr 17 '06 #4
If the fields are retrevied in DBName and then Path, then the lengths
would be 1,0 and # columns = 1 and bound probably # 1

Apr 17 '06 #5
Now I get a -1 on all 20 lines of my dropdown on the combo PLUS a
break/debug on this code:

Private Sub cboDBName_AfterUpdate()
Me.txtPathName = Me.cboDBName.Column(1)
End Sub

Apr 17 '06 #6
Keep it simple. Put this in the ControlSource of the text box.

= cboDBName.Column(2)

Jeff Pritchard
________________
Asken Research Pty. Ltd.
Access Database Developers
http://www.asken.com.au

"Parasyke" <kr************@yahoo.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Anyone with know the best way to do this one?
I have a form that is unbound (i.e. in its properties the form itself
is blank for the datasource). I have a combobox named "cboDBName" and a
textbox named "txtPathName". The combobox has as its datasource the
following:

SELECT [tblDatabases].[DBName] FROM tblDatabases ORDER BY
[tblDatabases].[DBName];

The table is simply a two column one with the database name (column 1)
and the database (path column 2).

I want the database path to appear in the textbox when the combobox
receives its choice. I used the following in the after_update code for
the combobox and this doesn't work:

Private Sub cboDBName_AfterUpdate()
Me.txtPathName = Me.cboDBName.Column(2)
End Sub

'Any ideas? thanks!

Apr 17 '06 #7
If it still does not work, please post the actual sql that you have as
the record source for the combo, because all of our suggestions are
based on assumptions about the sequence of fields in that query.

Apr 18 '06 #8
The binding and length are counts that based on the first field being
addressed by 1. But the column is 0 based and the first field is
addressed by using 0.

Apr 18 '06 #9
This works ...thanks!

Apr 18 '06 #10

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

Similar topics

1
by: Serious_Practitioner | last post by:
Hello, all - I want to get a customer name, address and so forth from a customer table using either a SELECT statement in a VBA procedure or in a query. The user should be able to put a customer...
2
by: rmorvay | last post by:
I am trying to dynamically build a dropdownlist and bind it to a cell in a grid. I tried to utilize the following code but I am stuck at the point where I bind the dropdownlist to the grid cell. ...
2
by: Premkumar-Prem_kumar2003 | last post by:
Database details:- Four Categories r there. Every Category includes some Description. DATA BINDING FOR SELECTED INDEX CHANGED EVENT:- Req:- 1. Combobox 2. ListBox (or) Textbox (with multiline...
2
by: SoftWhiteDelgiht | last post by:
Help me. I am obviously stupid! :-) I am just starting out with VB.Net and am trying to do a simple master/detail form with a SqlServer backend. I have created a combo box which is to populate with...
0
by: Larry Serflaten | last post by:
I am not sure how many are aware of this sort of data binding, but as it is new to many (classic) VB developers I thought I would post this once just to let people know of its availablility. ...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
1
by: Peter | last post by:
Hi, I'm trying to create a form that shows table rows in a listbox. Several comboboxes expand the foreign key fields into text values from the parent tables, and there are also some textboxes...
1
by: Monty M. | last post by:
Does anyone know how to perform two way data binding between a combo box and a listview. The listview is bound to a dataset table in code: Binding Bind = new Binding(); DataTable dt;...
3
by: Max | last post by:
Hello, I made a windows form with a combo box and 4 text boxes. All 5 objects should get their data from a data set which is populated in the form load method. The combo box has item ids. When...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.