Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Populate Label caption in a accordance to Selection from Combobox


Reply
 
Thread Tools Display Modes
  #1  
Old 01-23-2003, 10:07 AM
jon1jon1
Guest
 
Posts: n/a
Default 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
Reply With Quote
  #2  
Old 01-23-2003, 10:44 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default

Are you doing this in Access VBA, or in VB6?
__________________
Posting Guidelines
Reply With Quote
  #3  
Old 01-23-2003, 10:53 AM
jon1jon1
Guest
 
Posts: n/a
Default

VB6
Reply With Quote
  #4  
Old 01-23-2003, 10:56 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default

What do you have bound to the datacombo? An ADO datacontrol?
Is it on the tblClient table?
__________________
Posting Guidelines
Reply With Quote
  #5  
Old 01-23-2003, 10:59 AM
jon1jon1
Guest
 
Posts: n/a
Default

Yes my ado is linked to the table and the datacombo is bound to the ado
Reply With Quote
  #6  
Old 01-23-2003, 11:24 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default

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
__________________
Posting Guidelines
Reply With Quote
  #7  
Old 01-23-2003, 11:54 AM
jon1jon1
Guest
 
Posts: n/a
Thumbs up

I have been 2 days working on that,

thanks so much for your help thinker,

your a legend.
Reply With Quote
  #8  
Old 02-04-2003, 03:01 AM
jammydevil's Avatar
jammydevil jammydevil is offline
Regular
 
Join Date: Oct 2002
Location: UK
Posts: 56
Default

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
Reply With Quote
  #9  
Old 02-04-2003, 07:50 AM
jon1jon1
Guest
 
Posts: n/a
Default

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?
Reply With Quote
  #10  
Old 02-04-2003, 08:53 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default

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.
__________________
Posting Guidelines
Reply With Quote
  #11  
Old 02-04-2003, 01:34 PM
jammydevil's Avatar
jammydevil jammydevil is offline
Regular
 
Join Date: Oct 2002
Location: UK
Posts: 56
Default

Fixed it now thanks
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->