HELP: Trying to populate form fields posted on intranet from a dat

S

sam

Hi all,

I have designed a userform in excel and this form is posted on companys
local intranet site so others can user it to feed in their info,

Now, My question is: Is it possible to populate certain fields on the form
from a Database? For eg, they input their ID in the form and their other
details like their name, division etc populates automatically from the
database.

Is it possible to do this with access database? the form is on the companys
local intranet and the access database would be on some network drive or
where ever the form can pull the information from. Can this be done?

Thanks in Advance
 
J

Jeff

First Create a reference to Active X Data object Library 2.7 via
Tools-->references-->Microsoft Active X Data Objects Library 2.7

And Then somthing like the following if you need help post back.

Sub DatabaseQuery()
Dim ConnectionString As String
Dim Recordset As ADODB.Recordset
Dim SQL As String

'Connection.udl is the best way to get your
'connection string. Open "Notepad" and save as
'"Connection.udl" Then walk through the steps
ConnectionString = ""

'You can use Access' Query builder for the
'SQL Statement you need
SQL = "SELECT * FROM tblYourTable"

Set Recordset = New ADODB.Recordset

Call Recordset.Open(SQL, ConnectionString, adOpenKeyset, adLockReadOnly,
adCmdText)

If Not Recordset.EOF Then

With UserForm1

.Textbox1.Value = Recordset.Fields(0)
End With
End If
End Sub
 
J

JLGWhiz

Sure, it can be done if you have authority to access the data base, you know
where the data resides on the data base and you know how to write the code
to return the data from Access to Excel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top