L
Lone K.
Hi,
I got some code from Dough to get data from an Access database to a combobox
in word, and it worked perfectly.
But now I need the code that does following:
I pick an item from one list from a combobox in word (data from Access) and
then I automatically want it to get the next fields in the record to another
combo or list box (can also be a textbox).
So far I have following code - It does not get another field automatically
but operate individually.
Private Sub UserForm_Activate()
'Henter data fra database til Userformen - En record ad gangen.
'allocate memory for the database object as a whole and for the active
record
Dim myDataBase As Database
Dim myActiveRecord As Recordset
'Open a database
Set myDataBase = OpenDatabase("f:\Skabeloner\Udvikling\LOK\ICN.mdb")
'Access the first record from a particular table
Set myActiveRecord = myDataBase.OpenRecordset("Produkt", dbOpenForwardOnly)
'Loop through all the records in the table until the end-of-file marker is
reached
Do While Not myActiveRecord.EOF
cboProdukt.AddItem myActiveRecord.fields("Produktnavn")
'access the next record
myActiveRecord.MoveNext
Loop
'Then close the database
myActiveRecord.Close
myDataBase.Close
Set myDataBase = OpenDatabase("f:\Skabeloner\Udvikling\LOK\ICN.mdb")
'Access the first record from a particular table
Set myActiveRecord = myDataBase.OpenRecordset("Produkt", dbOpenForwardOnly)
'Loop through all the records in the table until the end-of-file marker is
reached
Do While Not myActiveRecord.EOF
cboProduktbeskrivelse.AddItem
myActiveRecord.fields("Produktbeskrivelse")
myActiveRecord.MoveNext
Loop
'Then close the database
myActiveRecord.Close
myDataBase.Close
I hope someone can help me.
Thanks, Lone
I got some code from Dough to get data from an Access database to a combobox
in word, and it worked perfectly.
But now I need the code that does following:
I pick an item from one list from a combobox in word (data from Access) and
then I automatically want it to get the next fields in the record to another
combo or list box (can also be a textbox).
So far I have following code - It does not get another field automatically
but operate individually.
Private Sub UserForm_Activate()
'Henter data fra database til Userformen - En record ad gangen.
'allocate memory for the database object as a whole and for the active
record
Dim myDataBase As Database
Dim myActiveRecord As Recordset
'Open a database
Set myDataBase = OpenDatabase("f:\Skabeloner\Udvikling\LOK\ICN.mdb")
'Access the first record from a particular table
Set myActiveRecord = myDataBase.OpenRecordset("Produkt", dbOpenForwardOnly)
'Loop through all the records in the table until the end-of-file marker is
reached
Do While Not myActiveRecord.EOF
cboProdukt.AddItem myActiveRecord.fields("Produktnavn")
'access the next record
myActiveRecord.MoveNext
Loop
'Then close the database
myActiveRecord.Close
myDataBase.Close
Set myDataBase = OpenDatabase("f:\Skabeloner\Udvikling\LOK\ICN.mdb")
'Access the first record from a particular table
Set myActiveRecord = myDataBase.OpenRecordset("Produkt", dbOpenForwardOnly)
'Loop through all the records in the table until the end-of-file marker is
reached
Do While Not myActiveRecord.EOF
cboProduktbeskrivelse.AddItem
myActiveRecord.fields("Produktbeskrivelse")
myActiveRecord.MoveNext
Loop
'Then close the database
myActiveRecord.Close
myDataBase.Close
I hope someone can help me.
Thanks, Lone