How do I find a record in a combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
When I open a form, I need to pre-select a record in combo box. Can can I do
this?
I thought perhaps I could use the findfirst, I know it works for finding
records based on what is selected in a combo box but how do you find records
programatically in a combo box?
Thanks,
 
Emilio,
Use the value selected in the combo as the "WhereCondition" argument in
the OpenForm method.
example...
DoCmd.OpenForm "frmYourDataForm" ,,, "CustID =
Forms!frmYourDialogForm!cboCustID"
hth
Al Camp
 
When I open a form, I need to pre-select
a record in combo box. Can can I do
this?

"Pre-select a record in a combo box" could happen in multiple contexts. Two
ways to pre-select: set the Default Value and set the Combo Box value from
VBA code. What would be appropriate would depend on the details...

Some clarifications that might help are: Bound or unbound combo box? Combo
box created with the wizard to find a record to display? How do you know
which record to pre-select?
I thought perhaps I could use the
findfirst, I know it works for finding
records based on what is selected in a
combo box but how do you find records
programatically in a combo box?

Actually, Combo Boxes are for "choosing a value from a list or entering a
value"... "finding a record" would be done separately (either, as you want,
before or, in the AfterUpdate event). You can set the value of the Combo
Box, but "finding a record" is one of those things you need to clarify.

Larry Linson
Microsoft Access MVP
 
Larry,
the form has a combo and the combo is bound. What it needs to happen is when
the form is opened select a record from the combo based the used id which is
in a global variable. I tried to follow Al Camp's suggestion bellow:
DoCmd.OpenForm stDocName, , , stLinkCriteria AND "strUserId =
[Forms]!frmEnterProjects!BuyerCode"
is giving me an error message "type mismatch"
the stLinkCriteria is:
stLinkCriteria = "[CaseID]=" & Me![List1]
 
Hello Anyone,
the form has a combo and the combo is bound. What it needs to happen is when
the form is opened select a record from the combo based the used id which is
in a global variable. I tried to follow Al Camp's suggestion bellow:
DoCmd.OpenForm stDocName, , , stLinkCriteria AND "strUserId =
[Forms]!frmEnterProjects!BuyerCode"
is giving me an error message "type mismatch"
the stLinkCriteria is:
stLinkCriteria = "[CaseID]=" & Me![List1]
 
Back
Top