Sean,
I've never used the stand alone VB6, so I don't understand how exactly the
data control feature works. I have used the ADO connection code for both
VBA in AutoCAD 2000 and in some Active Server Pages scripts.
The only way I know how to populate a form control like a listbox or
combobox is to:
1. Create the form & insert a listbox control and a textbox...say Listbox1 &
Testbox1.
2. Populate the listbox control using the Initialize event of the form.
3. Update the textbox using the Change event of the listbox.
This effectively uses the Access database as the Data Source. The following
is some generic code and is untested. But it should get you started.
Private Sub UserForm_Initialize()
' Set initial values for controls on form.
Dim strConnect As String
Dim conObject As New Connection
Dim rsObject As New Recordset
' Set ADO connection string
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=Absolute_Path;" & _
"Persist Security Info=False"
' Open ADO connection & recordsets
conObject.Open strConnect
rsObject.Open "My_Table", conObject, adOpenStatic, adLockReadOnly,
adCmdTable
' Populate Listbox1 with values from the "My_Field" field in the recordset
While Not rsObject.EOF
ListBox1.AddItem rsObject.Fields("My_Field").Value
rsObject.MoveNext
Wend
' Close recordsets & ADO connection
rsObject.Close
conObject.Close
Set rsObject = Nothing
Set conObject = Nothing
End Sub
Private Sub Listbox1_Change()
' Updates the Textbox1 value.
Textbox1.Text = Listbox1.Value
End Sub
Hope this helps.
Brian
"CAD MAN" wrote in message
news:8213966DCA3C287C32F34E125B58B79A@in.WebX.SaUCah8kaAW...
> I am trying to place some sort of a data control on my form that will link
> to an access database. Then i want to have a text box (or similar) gets
its
> values from the data control (database). In VBA 6 i insert a DATA Control
> and link it to a database-table-field. I cant figure out how to do this in
> Autocad VB.
>
> I can insert an ADO control but what can I link to it? list boxes, text
> boxes atc cant seem to get their values from it.
> -Sean
>
> "Brian Johnson" wrote in message
> news:F266400C178BBFAAF46F6CB62525D8EF@in.WebX.SaUCah8kaAW...
> > This is a bit of code I've been using to populate a listbox from an
Access
> > database file in VBA. You'll have to modify it to match your db fields,
> > etc. You'll also have to load the ADO 2.5 reference. I'm still working
> on
> > making it a bit more robust, but I know it works. It probably makes
more
> > sense to load the record set information into an array and then populate
> the
> > listbox using the array.
> >
> > I've never seen or used the DATACONTROL object. Is that VB6?
> >
> > Private Sub UserForm_Initialize()
> > ' Set initial values for controls on form.
> >
> > Dim strConnect, strCriteria As String
> > Dim conAECParts As New Connection
> > Dim rsParts, rsCategories As New Recordset
> > Dim intCount As Integer
> > Dim fldParts As Field
> >
> > strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> > "Data Source=C:\My Documents\AECCALogs.mdb;" & _
> > "Persist Security Info=False"
> >
> > conAECParts.Open strConnect
> > rsParts.Open "tblParts", conAECParts, adOpenStatic, adLockReadOnly,
> > adCmdTable
> > ' Substitute "tblParts" with a SQL string & change adCmdTable to
adCmdText
> >
> > rsCategories.Open "tblCategories", conAECParts, adOpenStatic,
> > adLockReadOnly, adCmdTable
> >
> > strCriteria = "Folder LIKE 'Steel'"
> > rsParts.Filter = strCriteria
> >
> > While Not rsParts.EOF
> > ListBox1.AddItem rsParts.Fields("File").Value
> > 'Debug.Print rsParts.Fields("File").Value
> > rsParts.MoveNext
> > Wend
> >
> > rsParts.Close
> > conAECParts.Close
> > Set rsParts = Nothing
> > Set conAECParts = Nothing
> >
> > End Sub
> >
> > Brian Johnson
> >
> > "CAD MAN" wrote in message
> > news:47746D716800D295D0C48BD96819FFF8@in.WebX.SaUCah8kaAW...
> > > I am trying to populate a combobox on a form with values from an
Access
> > > database. In standalone VBA i use a DATACONTROL. However, I cant find
it
> > in
> > > the Autocad VB environment (i checked references and objects).
> > > Can anyone help?
> > >
> >
>