Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
HELP: Populate corresponding userform text fields from access data | Excel Programming | |||
auto populate access database from an excel form | Excel Programming | |||
Fields in access database | Excel Programming | |||
Fields in access database | Excel Programming | |||
Using Access database to "populate" Excel Sheets | Excel Discussion (Misc queries) |