Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > problem setting the current value to display for my combo box..


Reply
 
Thread Tools Display Modes
  #1  
Old 12-07-2002, 08:59 AM
Stewie
Guest
 
Posts: n/a
Default problem setting the current value to display for my combo box..


Hello. right now what i do is open a record set to a table with all the values in that i want to put into the combo box's List.
for example, tbALLtown, and i put all Town fields in there.

Then i close that record set, and open a new one with an sql linking to the customer ID. so its like WHERE customerID = (variable). sort of thing

my problem is that i want to fill up the combo and then put its current value to the current customer when the form loads only using one record set because as you could imageon, opening up all the record sets is slowing down my database a lot.
i cant specify which record i want the combo to be and then fill it up because then i will only have one value in my combo box if you know what i mean.

is there anyway to get around this?
gman said before he had to go i should use .ITEMDATA but i did some research and cant find anything on how to use it.

sorry if you dont know what im talking about, hehe cant explain it very well.

-coogie
Reply With Quote
  #2  
Old 12-07-2002, 09:48 AM
Thinker Thinker is offline
Iron-Fisted Programmer

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

Ok, so the combobox has all the possible values. You need to set
the combo style = 2. Then, after you have loaded the combobox
(using additem), set its DataSource = theRecordsetForCustomers
and make the DataField = "TownID" (or whatever the field is
called in your customer table. When you have a row selected, it
will pull up the current town, but you can pull down the box and
select a new one. If you aren't using bound controls, there is
another way. Just set the text property of the combobox to the
value of the current town. If the town is changed, you will have
to copy the value back to the recordset before update.
__________________
Posting Guidelines
Reply With Quote
  #3  
Old 12-07-2002, 11:35 AM
Stewie
Guest
 
Posts: n/a
Default

alright cheers thinker ill give it a go

im not using data controls btw
Reply With Quote
  #4  
Old 12-07-2002, 11:41 AM
Thinker Thinker is offline
Iron-Fisted Programmer

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

Doesn't matter if datacontrol or not. You can still bind regular
controls to a recordset object.
__________________
Posting Guidelines
Reply With Quote
  #5  
Old 12-08-2002, 03:25 AM
Stewie
Guest
 
Posts: n/a
Default

is that a bad thing to do or does it not really much difference>
Reply With Quote
  #6  
Old 12-08-2002, 09:48 PM
Thinker Thinker is offline
Iron-Fisted Programmer

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

If you know what you are doing, it is really much better not to
bind controls. There are some situations where it really isn't
going to make any difference, and it can save some code. But I
would strongly encourage anyone to learn how to do database
programming without relying on automatic binding.
__________________
Posting Guidelines
Reply With Quote
  #7  
Old 12-09-2002, 01:28 AM
Stewie
Guest
 
Posts: n/a
Default

i think what im going to do now is include my combos in the sql for that tab page. because it wont be too big an sql seeing as its one tab page instead of about 3 now. and there wont be ambigious joins because Contacts etc are on different pages.

but i will still open a new recordset to fill each combo then close it, because this way i can do ORDER by for each combo, and it will be much smaller record sets for it to go from BEF to EOF while its filling up the combo.

i dont know how to use data controls ive been trying to do it manualy from day 2, when i think it was you who told me not to. heh thanks thinker

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