473,480 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Clear 2nd Combo on form (MS Access 2003)

Hi,

I have a form with 2 combo boxes.
I am not using them in the usual way, please read on:

In the 'Form Load' event, I have:

_______________________________________

dim folderspec as string
folderspec = "\\server\Images" (These folders are on our network
server in the office).
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 In fc
Me.Combo1.AddItem f1.name
Next
________________________________________
This lists all the sub-folder names within the main folder 'Images'
.....great so far. I then select a specific folder name from Combo1.

In Combo1 'After Update' I have this code:

_________________________________________

All the following variables are public.
'folder' is a public varable which holds the selected folder name from
combo1.

folder = ""
FileScript = ""
FolderPath = ""
FileSet = ""

folder = Me.Combo11.Column(0)

Dim strFiles As String
Set FileScript = CreateObject("Scripting.FileSystemObject")
Set FolderPath = FileScript.GetFolder("\\server\Images\" & folder)
Set FileSet = FolderPath.Files

For Each FileSelection In FileSet
Me.Combo2.AddItem FileSelection.name
Next

__________________________________________________ ___________

This works great the first time I select a folder from combo1, combo2
lists all the files within it, but the next time I se;ect another
folder from combo1, all those files are added to combo2 in addition to
the previous files instead of just changing them to the new files ? How
can I clear Combo2 for the next time I select from combo1 ?

I've tried n umerous things such as:

me.combo2 = null
me.combo2.text = ""

none of them seem to make any difference ? Combo2 always gets loaded
with more and more file names...I can understand why this happens, I
just cannot seem to clear combo2 ?

Thanks
David Gordon

Nov 13 '05 #1
1 1645
da*********@scene-double.co.uk wrote:
Hi,

I have a form with 2 combo boxes.
I am not using them in the usual way, please read on:

In the 'Form Load' event, I have:

_______________________________________

dim folderspec as string
folderspec = "\\server\Images" (These folders are on our network
server in the office).
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 In fc
Me.Combo1.AddItem f1.name
Next
________________________________________
This lists all the sub-folder names within the main folder 'Images'
....great so far. I then select a specific folder name from Combo1.

In Combo1 'After Update' I have this code:

_________________________________________

All the following variables are public.
'folder' is a public varable which holds the selected folder name from
combo1.

folder = ""
FileScript = ""
FolderPath = ""
FileSet = ""

folder = Me.Combo11.Column(0)

Dim strFiles As String
Set FileScript = CreateObject("Scripting.FileSystemObject")
Set FolderPath = FileScript.GetFolder("\\server\Images\" & folder)
Set FileSet = FolderPath.Files

For Each FileSelection In FileSet
Me.Combo2.AddItem FileSelection.name
Next

__________________________________________________ ___________

This works great the first time I select a folder from combo1, combo2
lists all the files within it, but the next time I se;ect another
folder from combo1, all those files are added to combo2 in addition to
the previous files instead of just changing them to the new files ? How
can I clear Combo2 for the next time I select from combo1 ?

I've tried n umerous things such as:

me.combo2 = null
me.combo2.text = ""

none of them seem to make any difference ? Combo2 always gets loaded
with more and more file names...I can understand why this happens, I
just cannot seem to clear combo2 ?

Thanks
David Gordon

Can you use RemoveItem or Clear prior to adding the items?

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1504
by: peterleeds | last post by:
Could anyone explain why Access 2003 is continuously calculating a continuous form, when it works perfectly in previous versions? On reading previous messages I gather that overlapping controls...
1
2673
by: Frank.Sebesta | last post by:
I have a employees database with a picture that shows on a form with employee information. Similar to the Northwinds sample database. When I print the record, my output is only the data and does...
2
2333
by: carmela_wong | last post by:
Hi all, I have converted a database from Access 2003 to Access 97. Everything gets neatly imported into the new database except for one form which continues to show a fatal error when I try to...
3
2442
by: erainc | last post by:
Hi There, I am trying to put a search box on my form in Access 2003. I tried doing it through a combo box, and the search part works, but the rest of the information on the form does not correlate...
2
2903
by: Horst JENS | last post by:
Hi group, have problems with combobox-control in a form (access 2003). I added VBA-Code to on-Change event of the control. If the user choose an value from the control, the filter of the form...
1
2193
by: Bface | last post by:
Hi All, I am stuck on a problem and hope someone can help me out. I have 8 users who will be using a form . For the users to access their accounts I use the SendKeys function, the user click on...
1
1453
by: sierra7 | last post by:
Hi all One of my users is complaining that when she types in a combo box, instead of matching characters and over-typing, she seems to be inserting e.g. On entering the combo she types her first...
6
4905
by: kfanarmy | last post by:
Hello; I am attempting to use a command button "Delete Current Assignment Record" on a form to delete a user-selected record from a table entitled "Registration" with Key field "Registration ID"....
11
2124
by: eyalco | last post by:
I have a receipt form (with continuous sub-form) where I need to issue many receipts in 1 form (from 12 to 36). I need to duplicate the details of each receipt (the only change every time is the...
24
3178
greeni91
by: greeni91 | last post by:
I am currently trying to put a find box at the top of a form I have created for reviewing machining methods. I have setup the box to show the Part Number field and take you to that record when...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7081
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6737
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4776
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.