View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jeff Jeff is offline
external usenet poster
 
Posts: 921
Default HELP: Trying to populate form fields posted on intranet from a dat

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



"sam" wrote:

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