Hi Haim,
I am not sure what method you to choose the value/item in combo Box control
from the value in textbox control; my testing shows it work on both
situations.
1. Create a new form with one combo box, one textbox, and one button.
2. The combo box is bounded to customers table, two columns: Customer ID
and company name.
3. Enter the customer id in the text box and click the button, the
corresponding value (companyname) is shown in the combo control, in other
word, the combo box's current selected value is based on the textbox's
value.
4. The code is as follows:
Option Compare Database
Option Explicit
Private Sub Command4_Click()
Dim stra As String
Dim i As Integer
Text2.SetFocus
stra = Text2.Text
For i = 0 To Combo0.ListCount - 1
If stra = Combo0.Column(0, i) Then
stra = Combo0.Column(1, i)
Exit For
End If
Next
Combo0.SetFocus
Combo0.Text = stra
End Sub
In adp, it still works, one thing we should notice is that the column order
may change in adp, we have an option to hide the primary key in ADP when
binding the combo box to table.
It seems your method is similar, if not, would you please post the detail
information so I can do some test for you?
Sincerely,
Alick Ye, MCSD
Product Support Services
Microsoft Corporation
Get Secure! - <
www.microsoft.com/security>
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Haim Beyhan" <
[email protected]>
| References: <
[email protected]>
<ujJ9Pq#
[email protected]>
|
| I have the two fields FRCOLID and FRCOLNAME on the continuouos form which
| FRCOLID is related to FICOLID in the first table. When I change FICOLID, I
| want FRCOLNAME to be displayed automatically. It is changed only when I
exit
| from the record. If I solve that problem , I will solve actually the other
| combobox problem also.
|
|
| Haim
|
|
| | > Hi Haim,
| >
| > It seems the problem is when you enter a number into the combo box it
does
| > not locate and highlight a matching record as expected; the autolist
| > functionality of a combo box does not work for a number field in an ADP
as
| > it does for a text field. In an mdb file, combo boxes based on number
| > fields or text fields will autolist as expected
| >
| > If this is the case, the Row Source property of the combo box must be
| > modified so that it converts the number to a character field. The
| > following example demonstrates a before and after Row Source property.
| The
| > sample is from an ADP that connects to the NorthwindCS database. The
| combo
| > box is based on the OrderID field of the Orders table. Row Source
| > property before modification:
| > SELECT "Orders"."OrderID" FROM "Orders"
| > Row Source property after modification:
| > SELECT CONVERT (char(5), OrderID) AS Expr1 FROM Orders ORDER BY
OrderID
| >
| > If the above does not help, could you please post what the approach you
| use
| > to do it in an mdb file? Could you post the reproduce steps?
| >
| > If you have any concerns or questions, please feel free reply to the
| > threads.
| >
| >
| >
| > Sincerely,
| >
| > Alick Ye, MCSD
| > Product Support Services
| > Microsoft Corporation
| > Get Secure! - <
www.microsoft.com/security>
| >
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| >
| >
| >
| >
| > --------------------
| > | From: "Haim Beyhan" <
[email protected]>
| > | Subject: Combobox in a continuous form
| > | Date: Sat, 4 Oct 2003 00:55:02 +0200
| > |
| > | I'm using Access 2002 and have an adp connecting SQL Server 2000.
| > | I have a continuous form in which there is a combobox that gets its
| > | rowsource from another table. This field is dependent on the first
| field.
| > | When I enter the first field, this combobox rowsource should be
changed
| > | automatically.
| > |
| > | There is an approach to do it in an mdb file and it works fine but it
| does
| > | not work in adp.
| > |
| > | You create a text box which has the field to be shown (adding it by
| > | relationship) and you put it on the combobox. When you enter the
textbox
| > you
| > | setfocus on the combobox and get the rowsource by code according th
the
| > | first field. Until now everything works fine. When you choose another
| > value
| > | from the combobox, the texbox that came with relationship, does not
get
| > the
| > | updated value so when I exit the combobox, the textbox gets the focus
| > again
| > | with the old value but when I exit the record totally, that textbox
| shows
| > | the updated field.
| > | Now, this approach worked fine in mdb but not in adp.
| > |
| > | Does anyone know how to solve the problem?
| > |
| > | Thanks in advance
| > |
| > | (e-mail address removed) (remove nospam. in order to send mail
directly)
| > |
| > |
| > |
| >
|
|
|