Combobox in a continuous form

H

Haim Beyhan

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)
 
V

Vadim Rapp

HB> You create a text box which has the field to be
HB> shown (adding it by relationship) and you put it
HB> on the combobox. When you enter the textbox you
HB> setfocus on the combobox and get the rowsource by
HB> code according th the first field. Until now
HB> everything works fine. When you choose another
HB> value from the combobox, the texbox that came with
HB> relationship, does not get the updated value so
HB> when I exit the combobox, the textbox gets the
HB> focus again with the old value but when I exit the
HB> record totally, that textbox shows the updated
HB> field. Now, this approach worked fine in mdb but
HB> not in adp.

Perhaps you could provide some code to illustrate the problem - what's the
rowsource of the combobox, what's in the events' procedures, etc. Sorry,
from your description above it's very hard to grasp what's going on. What
relationship? what is "first field"? what is "put it on the combobox"? and
so on.

Vadim
 
H

Haim Beyhan

Thanks for the reply. You're right it's difficult to understand the problem
here. Maybe I'll explain in different way. I have a select query that gets
the fields from two tables.

Table1: FI
FIID PK
FIDATE
FIFNO c(7)
FICOLID int
FISIZE c(2)

Table2: FR
FRID PK
FRFNO c(7)
FRCOLID int
FRCOLNAME c(15)
SELECT FI.FIID, FI.FIDATE, FI.FIFNO, FI.FICOLID, FR.FRCOLNAME, FI.FISIZE
FROM FI INNER JOIN FR ON FI.FIFNO = FR.FRFNO AND FI.FICOLID = FR.FRCOLID

This is the rowsource of the continuous form. Now, when I enter FICOLID, I
want FRCOLNAME to be displayed automatically. But FRCOLNAME does not change
until I exit from the record. This happens in mdb automatically but in adp
which is my case, it does not work. I tried to requery after update the
FICOLID. It changes then the FRCOLNAME but it's not a good idea to requery
every time and when you run requery it gets the cursor to the first line and
the first field.

Thanks in advance,

Haim Beyhan ([email protected]) remove nospam. in order to send mail
 
A

Alick [MSFT]

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)
|
|
|
 
H

Haim Beyhan

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
 
V

Vadim Rapp

Haim:

provide this information please:

1. recordsource of the form
2. controlsource of the textbox
3. controlsource of the combobox
4. rowsource of the combobox

Vadim


HB> Thanks for the reply. You're right it's difficult
HB> to understand the problem here. Maybe I'll explain
HB> in different way. I have a select query that gets
HB> the fields from two tables.

HB> Table1: FI
HB> FIID PK
HB> FIDATE
HB> FIFNO c(7)
HB> FICOLID int
HB> FISIZE c(2)

HB> Table2: FR
HB> FRID PK
HB> FRFNO c(7)
HB> FRCOLID int
HB> FRCOLNAME c(15)
HB> SELECT FI.FIID, FI.FIDATE, FI.FIFNO, FI.FICOLID,
HB> FR.FRCOLNAME, FI.FISIZE FROM FI INNER JOIN FR ON
HB> FI.FIFNO = FR.FRFNO AND FI.FICOLID = FR.FRCOLID

HB> This is the rowsource of the continuous form. Now,
HB> when I enter FICOLID, I want FRCOLNAME to be
HB> displayed automatically. But FRCOLNAME does not
HB> change until I exit from the record. This happens
HB> in mdb automatically but in adp which is my case,
HB> it does not work. I tried to requery after update
HB> the FICOLID. It changes then the FRCOLNAME but
HB> it's not a good idea to requery every time and
HB> when you run requery it gets the cursor to the
HB> first line and the first field.

HB> Thanks in advance,

HB> Haim Beyhan ([email protected]) remove
HB> nospam. in order to send mail

HB> message
HB> HB>>> You create a text box which has the field to be
HB>>> shown (adding it by relationship) and you put it
HB>>> on the combobox. When you enter the textbox you
HB>>> setfocus on the combobox and get the rowsource
HB>>> by code according th the first field. Until now
HB>>> everything works fine. When you choose
HB>>> another value from the combobox, the texbox that
HB>>> came with relationship, does not get the updated
HB>>> value so when I exit the combobox, the textbox
HB>>> gets the focus again with the old value but when
HB>>> I exit the record totally, that textbox shows
HB>>> the updated field. Now, this approach worked
HB>>> fine in mdb but not in adp.
HB>>
HB>> Perhaps you could provide some code to illustrate
HB>> the problem - what's the rowsource of the
HB>> combobox, what's in the events' procedures, etc.
HB>> Sorry, from your description above it's very hard
HB>> to grasp what's going on. What relationship? what
HB>> is "first field"? what is "put it on the
HB>> combobox"? and so on. Vadim ---------------------
HB>> Vadim Rapp Consulting
HB>> SQL, Access, VB Solutions
HB>> 847-685-9073
HB>> www.vadimrapp.com
HB>>
 
A

Alick [MSFT]

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)
| > |
| > |
| > |
| >
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top