LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default UserForm question

I need to get some values from an Access database and place them into
a worksheet. I am thinking the best way to do this would be to create
a user form with a few controls (combo boxes) that would allow them to
pick the different items they need from the Access database (a job
number, and a status option). They would then click OK on the form
and the appropriate fields would be populated on the worksheet. Does
this sound like the best method to accomplish this? I have started
creating a userform with one combo box to lookup the job number but it
is not listing any data.... the code I am using is below: THanks!

Private Sub ComboBox1_Change()
On Error GoTo UserForm_Initialize_Err
Dim i As Integer
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=U:\Intranet\pmdata.mdb"
rst.Open "SELECT [JobNumber], [JobName] FROM mstJobs WHERE
[CONTRACTSTATUS] = TRUE ORDER BY [JobNumber];", _
cnn, adOpenStatic
rst.MoveFirst

With Me.ComboBox1
.Clear
Do
.AddItem rst![JobNumber]
rst.MoveNext
Loop Until rst.EOF
End With

UserForm_Initialize_Exit:
On Error Resume Next
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
Exit Sub
UserForm_Initialize_Err:
MsgBox Err.Number & vbCrLf & Err.Description, vbCritical, "Error!"
Resume UserForm_Initialize_Exit
End Sub

 
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
Userform question Greg[_18_] Excel Programming 2 May 28th 05 11:17 AM
Userform Question Ray Batig Excel Programming 5 March 23rd 05 11:47 PM
UserForm Question bforster1[_25_] Excel Programming 1 November 6th 04 01:21 PM
Userform Question Ray Batig Excel Programming 0 September 20th 04 12:37 AM
userform question keyur Excel Programming 2 April 14th 04 04:49 PM


All times are GMT +1. The time now is 02:14 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"