I'm having problems with the combo boxes

ivan86s

Registered User.
Local time
Today, 08:05
Joined
May 20, 2008
Messages
10
Hello, i'm new to this forum and to MS Access in general so any help would be appreciated.

I'm trying to do the following:

1)I have to combo boxes on my form, Combo1, and Combo2
2)Combo1 is visible, Combo2 is invisible at first
3)when i select an entry in Combo1, Combo2 becomes visible, and the choices in Combo2 depend on what i chose in Combo1

Example:
Choices in Combo1:
-Firstnames
-Lastnames
Choices in Combo2
-If Firstnames chosen in Combo1
--[list of first names]
-If Lastnames chosen in Combo1
--[list of last names]

(NOTE -(dash) is used for indentation, not a part of an actual code)
Private Sub Combo1_Click()
--Dim c As Long
--c = Forms![Main Menu]![Combo1].ListIndex

--If c = 0 Then ' if first index is chosen
----Forms![Main Menu]![Combo2].Visible = True
----Forms![Main Menu]![Combo2]!ControlSource = [Firstnames]
--Else If c = 1 Then ' if second index is chosen
----Forms![Main Menu]![Combo2].Visible = True
----Forms![Main Menu]![Combo2]!ControlSource = [Lastnames]
--End If
End Sub

[Firstnames] and [Lastnames] are columns in the Table names

i tried different variations insted of the [Firstnames] and [Lastnames],
I had ControlSource = [names].[Firstnames] -> (Error 2465, see below)
I had ControlSource = "Fistnames" -> (Error 451, see below)
They all give me errors, Does anyone knows what the error might be or if there is a better way of doing it


-> ERROR 2465 Microsoft Access can't find the field '|' refered to in your expression.
-> ERROR 451 Property let procedure not defined and property get procedure did not return an object
 
Hello
(Disclaimer: I'm quite new to Access and I don't really understand code, so this suggestion comes from a rather inexperienced user.)
Maybe you could try "cascading combo boxes".
Would this help: "http://office.microsoft.com/en-us/access/HA011730581033.aspx"?
 
Why not populate just one combobox with a union query containing both first and last names?
 
I need it to be different lists, right now i'm only practicing with names, but eventually i'll have 12 tables with up to 10 fields in each. So now i'm just trying to find a way to extract info from one table based on the choices in another using VB. It would be impossible to manage it in a querry and even more impossible to put it all in one table.

Thanks for replyes
 
I appreciate your suggestions, but I need to know how to assign a field/column to a Combo using VisualBasic, the querry will not serve my purposes in the long run. My data is very diverse and unsortable (i tried), so now i need to design a little software in VB to efficiently navigate through it.
So, does anyone know how to do the exaple mentiond above?

thanks in advence!
 
You are trying to set the control source, but instead should be setting the ROW SOURCE of the 2nd combo box (in the combo1 AFTER UPDATE EVENT) to:

"Select " & Me.Combo1NameHere & " From YourTableNameHere"
 
You are trying to set the control source, but instead should be setting the ROW SOURCE of the 2nd combo box (in the combo1 AFTER UPDATE EVENT) to:

"Select " & Me.Combo1NameHere & " From YourTableNameHere"

I don't fully understand what you mean.
[Form]![Control]!RowSource = "Select
.[Field] from
"
doesn't give me any errors, and it creates a combobox with the right number of elements but it's empty, i'm not sure where to go from here. Where do i put the AfterUpdate()???

thx.
 
cbrs01.png



cbrs02.png



cbrs03.png



cbrs04.png



cbrs05.png
 
Thanks boblarson, that did it.
Thanks for the Custom made tutorial, i hope it wasn't too much trouble for you.
Thank you again very much.:D:D
 
Thanks boblarson, that did it.
Thanks for the Custom made tutorial, i hope it wasn't too much trouble for you.
Thank you again very much.:D:D

Nope, wasn't too much trouble. I am way more visual and know that it can help when the descriptions aren't getting through. Plus, SnagIt is an awesomely easy tool to use to do up the screenshots.
 

Users who are viewing this thread

Back
Top Bottom