 |
 |

01-23-2003, 10:07 AM
|
|
|
Populate Label caption in a accordance to Selection from Combobox
|
Hey,
Ive posted this question a few times and still got no where, if I have a client table in access with 2 fields: name and telephone no.
I have a datacombo on the form from which i select a client name. On selecting a particular name from the combobox I wish the corresponding telephone number to appear in the label Telephone on the same form
I have being trying the following code, I know may look very bad but its all i have come up with. I placed this query in the change event of the combo:
lblCtel.Caption = "Select [Telephone_No] from tblClient where [Client_Name]=" DataCombo1.Text
Any help would br great
Thanks in advance
|
|

01-23-2003, 10:44 AM
|
|
Iron-Fisted Programmer
Retired Moderator * Guru *
|
|
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
|
|
|
Are you doing this in Access VBA, or in VB6?
|
|

01-23-2003, 10:53 AM
|
|
|
|

01-23-2003, 10:56 AM
|
|
Iron-Fisted Programmer
Retired Moderator * Guru *
|
|
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
|
|
|
What do you have bound to the datacombo? An ADO datacontrol?
Is it on the tblClient table?
|
|

01-23-2003, 10:59 AM
|
|
|
|
Yes my ado is linked to the table and the datacombo is bound to the ado
|
|

01-23-2003, 11:24 AM
|
|
Iron-Fisted Programmer
Retired Moderator * Guru *
|
|
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
|
|
Don't know the name of your datacombo or datacontrol so using
the default names...
Code:
Private Sub DataCombo1_Click(Area As Integer)
With Adodc1.Recordset
.MoveFirst
.Find "Client_Name = '" & DataCombo1.Text & "'"
If Not (.BOF Or .EOF) Then
lblCtel.Caption = !Telephone_No
End If
End With
End Sub
|
|

01-23-2003, 11:54 AM
|
|
|
|
I have been 2 days working on that,
thanks so much for your help thinker,
your a legend.
|
|

02-04-2003, 03:01 AM
|
 |
Regular
|
|
Join Date: Oct 2002
Location: UK
Posts: 56
|
|
I've tried doing the same thing but using a text box, but I get an error
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query
What could be the cause of this error and how would you solve it?
Cheers 
|
|

02-04-2003, 07:50 AM
|
|
|
|
Well Im not sure i can give you alot of help but I know that there are alot of different types of combo boxes make sure your using a datacombo. I had a similar problem and realised it was a dbcombo i was using. Are you using a datacombo?
|
|

02-04-2003, 08:53 AM
|
|
Iron-Fisted Programmer
Retired Moderator * Guru *
|
|
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
|
|
|
Take a look at the query of the original post...
Select [Telephone_No] from tblClient where [Client_Name]=" DataCombo1.Text
The only possible way this could be updateable query is if
Telephone_No was a unique field (usually primary key). But even
then, it doesn't make any sense to change the value of a unique
field. Updateable queries are ones that contain a field that is
unique and other fields that you might want to update. Also,
they have to be opened with attributes that allow them to be
updateable, such as a LockType that isn't readonly and a
CursorType that isn't forward only.
|
|

02-04-2003, 01:34 PM
|
 |
Regular
|
|
Join Date: Oct 2002
Location: UK
Posts: 56
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|