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: 411
Default Populate combobox with sql from DAO

With Excel 2000 and windows 2000, I'm attempting to use the following
code to populate a combobox, but I'm getting the
compile error: "method or data member not found" one the
with statement:

With rstFromQuery
..AddItem is highlighted in blue

Does anyone have suggestions about what I'm doing wrong?

Thanks,

Dan

Sub CreateRecordSet()
On Error GoTo CreateRecordSetErrorHandler
Dim oldDbName As String
Dim wspDefault As Workspace
Dim dbsEAIQuote As Database
Dim strSQL As String
Dim strCompetitorPart As String
Dim strEAIPart As String
Dim rstFromQuery As Recordset

strCompetitorPart = Sheet6.TextBox3.Text
strEAIPart = Sheet6.ComboBox2.Text


'Set the path to the database
oldDbName = "K:/Customer Service/Quote/Database/EAIQuote_be.mdb"

'Create a default workspace Object
Set wspDefault = DBEngine.Workspaces(0)

'Create a Database object
Set dbsEAIQuote = wspDefault.OpenDatabase(oldDbName)

'The SQL statement
strSQL = "SELECT tblCrossNoDash.Scrubbed, " & _
"tblCrossNoDash.EAIPartNumber FROM tblCrossNoDash " & _
"WHERE (tblCrossNoDash.Scrubbed= '" & strCompetitorPart & "')"

'Create a Snapshot Type Recordset from the SQL query
Set _
rstFromQuery = dbsEAIQuote.OpenRecordset(strSQL, dbOpenSnapshot)

'load up combobox
With rstFromQuery
If Not .BOF Then .MoveFirst
While Not .EOF
.AddItem rstFromQuery
.MoveNext
Wend
End With
'Show the number of fields returned
'MsgBox "there are " & rstFromQuery.Fields.Count & _
'" fields that were returned"

'Move to the last record in the recordset
' rstFromQuery.MoveLast

'Put the EAI part number in textbox2
Sheet6.ComboBox2.DropDown = rstFromQuery!EAIPartNumber
'Show the number of records returned
' MsgBox "there are " & rstFromQuery.RecordCount & _
' " records that were returned"
Exit Sub
CreateRecordSetErrorHandler:

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
Populate Combobox Alex Excel Programming 2 July 27th 07 04:04 PM
Populate a ComboBox Greg Maxey[_3_] Excel Programming 3 March 22nd 07 06:23 PM
use selected value from one combobox to populate another combobox rjudge[_7_] Excel Programming 3 April 14th 06 02:01 PM
Populate combobox Pat Excel Programming 1 December 10th 04 05:33 PM
Populate a combobox Rory[_3_] Excel Programming 2 June 9th 04 04:20 PM


All times are GMT +1. The time now is 06:48 AM.

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"