get value from combo box, save in variable, pass it to query

viwaltzer

Registered User.
Local time
Today, 07:43
Joined
Sep 12, 2012
Messages
15
I'm new to access. I need to update a mini system. I can't find where or how to capture the value they selected in combo box. I see I can use something like ComboName.selected, but wherever I've put it hasn't done anything or given me an error.

After getting that value, they want to be able to update all records in table that has this value. So I need to pass this variable to a query.

Any help would be appreciated. Thanks!!:banghead:
 
Why can't you just use the reference from the query:

An example would be -

Update TableNameHere Set FieldNameHere = "Whatever"
WHERE OtherFieldName = [Forms]![YourFormNameHere]![ComboNameHere]
 
I see I can use something like ComboName.selected, but wherever I've put it hasn't done anything or given me an error.
The correct way to use the Selected method is:
Code:
Me.Combobox.Selected(0) = True
where 0 refers to the first row so ifyou want to highlight a different row it's the row minus 1. But note that it's not zero based when you have the Column Headings property on.
 
Are you using a multi-select field for the combo box? That would explain why my code wouldn't work for you and why you think you need to use .selected. If so, it is going to require going about things differently than you normally would.
 
This is what I've done & it's still not working the way I want.

Code in combo box named EventSelect:

SELECT Event.Event_ID, (Event.Event_ID & " " & Event.Organization) AS EventDisplay
FROM Event
union
select 0,'0 All Events'
from Event
ORDER BY Event.Event_ID;

(works fine in box)

the form record source is:

SELECT (Tests.Event_ID & " " & Event.Organization) AS EventDisplay, *
FROM Tests INNER JOIN Event ON Tests.Event_ID = Event.Event_ID
WHERE ((([Tests].[Event_ID] & " " & [Event].[Organization])=[Forms]![frmTests]![EventSelect]))
ORDER BY Tests.Event_ID;

When I select an event in the combo box, I want the form populated with everything that meets the criteria. If I run the record source query & substitute a value from the combo box, I do get data.

What am I doing wrong? Thanks a lot for everyone's help.
 
I figured out what my problem was. Thanks for leading me there.:)
 

Users who are viewing this thread

Back
Top Bottom