Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBA FROM WORD 2003 TO READ ACCESS DATABASE 2003

54 views
Skip to first unread message

Joey

unread,
Aug 22, 2010, 6:29:45 AM8/22/10
to
Not sure if I should post this under word vba or access because it
involves both.

I have an access database where I have different fields having
relationships with other databases e.g. I have a field which is called
Branch then I have a relationship with a Branch table where in the
original database when you get to the Branch field you click on the
combobox in access and select a different branch (so its like a drop
down in the access database allowing you to select either CT, JHB or
DBN.

From word 2003 I am reading info from that database as follows:

strADNDB = "c:\apps\adndatabase.mdb"
strMASTPATH = ""
Set ADNDataBase = OpenDatabase(strADNDB)
intRecords = "0"
Set rdAuthor = ADNDataBase.OpenRecordset("Author")
For intRecords = 0 To rdAuthor.RecordCount - 1
If rdAuthor.Fields(1).Value = Application.UserName Then
If rdAuthor.Fields(10).Value = "1" Then
OptionButton1.Value = True
End If
If rdAuthor.Fields(10).Value = "2" Then
OptionButton2.Value = True
End If
If rdAuthor.Fields(10).Value = "3" Then
OptionButton3.Value = True
End If
rdAuthor.MoveNext
Else
rdAuthor.MoveNext
End If
Next intRecords
rdAuthor.Close
ADNDataBase.Close

This works well but I battled to determine that the field value "1" is
actually JHB and field value "2" is CT and field value "3" is DBN.

I would want to have a different instruction where I can actually read
the text which is JHB or CT or DBN.

So it should say:
If rdAuthor.Fields(10).Value = "JHB" Then
OptionButton2.Value = True
End If
etc.

However, because the drop down is read from another table it uses a
number to see if you selected the first one in the list or the second
or the third.

For this option it is ok but my next step is where I have 200
departments and I will take hours to try and figure out which
department is actually which number.
Any ideas where I can maybe say If rdAuthor.Fields(10).Text or
TextValue or whatever is "JHB" Then
.......

Hope you understand what I mean. Any help will be greatly appreciated.

Is there a way I can upload my database then you can see what I mean
if you don't understand.

Doug Robbins - Word MVP

unread,
Aug 22, 2010, 7:51:19 PM8/22/10
to
See response in word.vba.general

Note these newsgroups are no longer hosted by Microsoft and are now orphans
in the wilderness.

As a replacement for the newsgroups, Microsoft has created forums that can
be accessed at:

http://social.answers.microsoft.com/Forums/en-US/category/officeword

--
Hope this helps,

Doug Robbins - Word MVP
dkr[atsymbol]mvps[dot]org

"Joey" <jo...@ultimatefunctions.co.za> wrote in message
news:10f7e158-f301-4d18...@j8g2000yqd.googlegroups.com...

0 new messages