How to code DBCombo1, DBCombo2 ... (Again) 
Author Message
 How to code DBCombo1, DBCombo2 ... (Again)

Thanks for some reply to my Q regarding HowTo do DBCombo in pure code.
I try to be more direct:

I need to replace the DBList-function, in the code following, to
DBCombo-function.
Is there a straight way for doing this, in code using VB5, please.
...
Option Explicit
  Dim DB As DAO.Database
  Dim DB2 As DAO.Database
  Dim RS1 As Recordset
  Dim RS2 As Recordset
Private Sub cmdRS1_Click()
  Set Data1.Recordset = RS1
  Data1.Refresh
  DBList1.ListField = "Author"
End Sub
Private Sub cmdRS2_Click()
  Set Data1.Recordset = RS2
  Data1.Refresh
  DBList1.ListField = "CompanyName"
End Sub
Private Sub Form_Load()
  Set DB = OpenDatabase("C:\Program Files\DevStudio\Vb\biblio97.mdb")
  Set DB2 = OpenDatabase("C:\Program Files\DevStudio\Vb\nwind.mdb")
  Set RS1 = DB.OpenRecordset("Authors")
  Set RS2 = DB2.OpenRecordset("Customers")
End Sub
...
Any reply will be appreciated.
Thanks, Lennart



Sat, 26 Aug 2000 03:00:00 GMT  
 How to code DBCombo1, DBCombo2 ... (Again)

I'd like to have some comment on your code:

Quote:

>Thanks for some reply to my Q regarding HowTo do DBCombo in pure code.
>I try to be more direct:

What do you mean 'replace  DBList-function to DBCombo-function'?
i guess you want to use (replace) the DBCombo control instead of DBList
control, if that's the case,
you can :
1. At design time, add a DBCombo into the form and use Edit-Replace to
change the name in the code or
2. Create a new DBCombo at run time by, insert a DBCombo (DBCombo1) at
design time, set its visible to false, set index to 0 then at the form load
event, 'clone' it by:
    Dim DBcbo as new DBCombo1
remember, it is a control array, each new one will have its index increase
by 1.
As far as I know, create the (DB) List box or Combo box at the run time
doesn't give you any advantage over the design time

Quote:
>I need to replace the DBList-function, in the code following, to
>DBCombo-function.
>Is there a straight way for doing this, in code using VB5, please.
>...
>Option Explicit
>  Dim DB As DAO.Database
>  Dim DB2 As DAO.Database
>  Dim RS1 As Recordset
>  Dim RS2 As Recordset

Why you need to declare db and db2 as DAO.Database, in both VB4 & 5, I can
just
declare them AS Database.  In an acticle in VBPJ, it said that MS will
replace DAO with RDO or ADO or what ever, but I'm sure Database object is
stay.
Quote:
>Private Sub cmdRS1_Click()
>  Set Data1.Recordset = RS1
>  Data1.Refresh
>  DBList1.ListField = "Author"
>End Sub
>Private Sub cmdRS2_Click()
>  Set Data1.Recordset = RS2
>  Data1.Refresh
>  DBList1.ListField = "CompanyName"
>End Sub
>Private Sub Form_Load()
>  Set DB = OpenDatabase("C:\Program Files\DevStudio\Vb\biblio97.mdb")
>  Set DB2 = OpenDatabase("C:\Program Files\DevStudio\Vb\nwind.mdb")
>  Set RS1 = DB.OpenRecordset("Authors")
>  Set RS2 = DB2.OpenRecordset("Customers")
>End Sub
>...
>Any reply will be appreciated.
>Thanks, Lennart




Thu, 31 Aug 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to code DBCombo1, DBCombo2 ...

2. <click> Data1.Recordset.Bookmark = DBCombo1.SelectedItem

3. DBCombo1 question..please help

4. Rasing an event ...again, now with Dev's code

5. Pausing VBA code (Again!)

6. HELP. Trying again on fixing this code

7. code to setup header....again

8. Random - again. This time with example-code

9. Newbie Question: How to code Find again (F3) for text search

10. MSComm again...this time with our code...

11. Printer Control codes (Again)

12. Printer Control codes (Again?)

 

 
Powered by phpBB® Forum Software