
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