Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2007

Tip: Looking for answers? Try searching our database.

search valors in access table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SAM S.L - 01 Oct 2007 21:53 GMT
hello!
I like search from a userform in word one valor in access table. The
userform demand a number and with this, consult an access table and recover
data to insert in the userform but i not able to programming this

thanks in advance and sorry for my bad english
Doug Robbins - Word MVP - 02 Oct 2007 03:11 GMT
The best thing is probably to have a combobox on the userform into which you
load the data from a table or query in the Access Database.

The following code can be used to load either a listbox or a combobox

Private Sub UserForm_Initialize()
   Dim db As DAO.Database
   Dim rs As DAO.Recordset
   Dim NoOfRecords As Long
   ' Open the database
   Set db = OpenDatabase("D:\Access\ResidencesXP.mdb")
   ' Retrieve the recordset
   Set rs = db.OpenRecordset("SELECT * FROM Owners")
   ' Determine the number of retrieved records
   With rs
        .MoveLast
        NoOfRecords = .RecordCount
        .MoveFirst
   End With
   ' Set the number of Columns = number of Fields in recordset
   ListBox1.ColumnCount = rs.Fields.Count
   ' Load the ListBox with the retrieved records
   ListBox1.Column = rs.GetRows(NoOfRecords)
   ' Cleanup
   rs.Close
   db.Close
   Set rs = Nothing
   Set db = Nothing
End Sub

Then you use the .BoundColumn property of the Combobox to specify the column
that contains the required data.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> hello!
> I like search from a userform in word one valor in access table. The
> userform demand a number and with this, consult an access table and
> recover data to insert in the userform but i not able to programming this
>
> thanks in advance and sorry for my bad english
SAM S.L - 02 Oct 2007 08:29 GMT
Ok.
Thank you

> The best thing is probably to have a combobox on the userform into which
> you load the data from a table or query in the Access Database.
[quoted text clipped - 35 lines]
>>
>> thanks in advance and sorry for my bad english
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.