[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

combo box add item

Posted on 2004-04-01
5
Medium Priority
?
922 Views
Last Modified: 2013-12-25
Hi all

I have 2 combobox where the items are being autopopulated from 2 different lookup tables

At runtime if I view items in combo1 everything ok
If I view items in combo2 it has items from combo1 and not from specific lookup

Close form
At runtime if I view items in combo2 everything ok
If I view items in combo1 it has items from combo2 not from specific lookup

Which ever Combobox I select first it populates theother combobox with the same item data.

The code below
Any help highly apprecaited
Shaz

Private Sub Form_Load()
Dim xlApp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")

Dim i As Integer
Dim TotalCellCount As Integer
Dim Selectcell As String


Set xlbook = xlApp.Workbooks.Open("c:\SIC Look Up Table.xls")


Set xlsheet = xlbook.Worksheets(1)


TotalCellCount = ActiveSheet.Range("A1").CurrentRegion.Rows.Count


For i = 1 To TotalCellCount

Range("A" & i).Select
Selectcell = Application.ActiveCell.Value
Combo1.AddItem Selectcell
Next i

Set xlbook = xlApp.Workbooks.Open("c:\SIC Look Up 4.xls")

Set xlsheet = xlbook.Worksheets(1)
TotalCellCount1 = ActiveSheet.Range("A1").CurrentRegion.Rows.Count
For p = 1 To TotalCellCount1

Range("A" & p).Select
Selectcell1 = Application.ActiveCell.Value
combo2.AddItem Selectcell1
Next p

Set xlApp = Nothing
Set xlbook = Nothing
Set xlsheet = Nothing

0
Comment
Question by:Shezad Ahmed
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 13

Expert Comment

by:crazyman
ID: 10730949
Any code in your combo events eg:Click,Change etc..
0
 
LVL 13

Expert Comment

by:crazyman
ID: 10730958
Also
What is Range and Application
Instead of Application.ActiveCell.Value should it be xlApp.ActiveCell.Value

?
0
 

Author Comment

by:Shezad Ahmed
ID: 10731225
Hi Crazyman

If I change Application.ActiveCell.Value to  xlApp.ActiveCell.Value then  combo1 only fills with the first item in row a.
Range just moves down coulmn A and replaces i with the next number.

What I have noticed is a number of instances of excel.exe running. Could this be the cause. Maybe locking the excel spreadsheet.
Surely there should be only one instance running

I do not have any Click,Change etc..

Cheers
Shezad
0
 
LVL 5

Accepted Solution

by:
Alok-Agarwal earned 1500 total points
ID: 10731403
Hi,

Before setting xlbook to  "SIC Look Up 4.xls" ensure that you have closed the workbook by using


Workbooks.close

Hope that helps.

Thanks
Alok
0
 

Author Comment

by:Shezad Ahmed
ID: 10732875
Thanks everyone
I placed workbooks.close before setting  "SIC Look Up 4.xls
And also I placed workbooks.close and xlapp.quit before I set to nothing

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question