Open record from combobox

foshizzle

Registered User.
Local time
Today, 04:57
Joined
Nov 27, 2013
Messages
277
I have a form "frmRequisitions" with unbound controls which is used for data entry.

I've placed a combobox in the form header which I would like to use to filter previously saved records from the "Description" record field, then open that previously saved record on the existing (opened) form.

How might I go about doing this? I've placed the following code in the combo box's After Update event. The form appears to refresh, but it doesn't bring up the selected record based on the Description field.


Code:
DoCmd.OpenForm FormName:="frmRequisitions", WhereCondition:="[Description]=" & Chr(34) & Me.cboBrowse & Chr(34)
 
Description is a text field so needs text delimiters.
Use one of these

Code:
DoCmd.OpenForm "frmRequisitions",,,"Description='" & Me.cboBrowse & "'"

Or
Code:
DoCmd.OpenForm FormName:="frmRequisitions", WhereCondition:="[Description]='" & Me.cboBrowse & "'"
 
Thanks for your help. I tried both your codes but I'm unfortunately receiving the same results. It's a fairly simple database; I'm uploading it here if you have a chance to review the combobox/form.
 

Attachments

Whilst I'm sure I could fix it for you, there's a much better solution.
Unbound forms are almost always a bad idea.
You make unnecessary work for yourself having to write code that Access does automatically in bound forms

So change all your textbox controls from unbound to bound.
You can then get rid of almost all of your code and the form will filter correctly.
To add new records, you would then either open the form in data entry mode or click on New record button or use the navigation buttons at the top
 
Lol - thanks, that fixed it. I originally took the unbound route because the last database I had to make was quite big and complicated.
 

Users who are viewing this thread

Back
Top Bottom