LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default HELP PLEASE: Populate certain userform fields from access database

Hi All,

I am trying to pull some information from access database and populate some
fields in excel userform. So for example, if a user inputs his "User Id:" in
User Id Textbox, certain fields like Name, Address, ect. associtated to that
user will populate on the userform

Here is the code I have worked on so far, But it is not working

Private Sub UserId_AfterUpdate()
Dim r As Long
Dim cn As Object
Dim rs As Object

Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " & _
"Data Source=C:\My Documents\User_Info.accdb; Jet OLEDB:Database
Password=User1234; "

rs.Open "Loan_Presentation", cn, 1, 3, 2

Set Rng = Range("User_Id")

For Each Dn In Rng
On Error Resume Next

If Dn.Value = CLng(UserId.Value) Then

Name.Value = Dn.Next
Address.Value = Dn.Next.Next

End If
Next Dn

Application.DisplayAlerts = False

rs.Close
Set rs = Nothing

cn.Close
Set cn = Nothing

End Sub

Thanks in Advance
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP: Populate corresponding userform text fields from access data sam Excel Programming 1 October 5th 09 08:28 PM
auto populate access database from an excel form sam Excel Programming 1 July 1st 09 09:09 PM
Fields in access database Justin Philips Excel Programming 1 March 7th 06 02:34 AM
Fields in access database Justin Philips Excel Programming 1 March 6th 06 10:55 PM
Using Access database to "populate" Excel Sheets maacmaac Excel Discussion (Misc queries) 1 September 19th 05 05:06 PM


All times are GMT +1. The time now is 02:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"