Re: dropdown list cbo to find record



Hi Tori,

"However, because my customer name is now an unbounded data field"

when you make a control to be used as a lookup or a filter, it is not bound -- and I normally put these in the form header so they are not confused with data controls.

If Customer Name is a field in your RecordSource, you should have a bound control to display and edit it.

~~~

for finding records:

Make one or more unbound (no ControlSource) combos on your form (like in the header). Let the first column be invisible and be the primary key ID of the RecordSource of your form and then, on its AfterUpdate event...

=FindRecord()

this code goes behind the form:

'~~~~~~~~~~~~~~~~~~~~
Private Function FindRecord()

'if nothing is picked in the active control, exit
If IsNull(Me.ActiveControl) Then Exit Function

'save current record if changes were made
If me.dirty then me.dirty = false

'declare a variable to hold the primary key value to look up
' NOTE: this assumes that the primary key is an autonumber
' or a long integer data type -- if this is not the case,
' modify accordingly
Dim mRecordID As Long

'set value to look up by what is selected
mRecordID = Me.ActiveControl

'clear the choice to find
Me.ActiveControl = Null

'find the first value that matches
Me.RecordsetClone.FindFirst "SomeID = " & mRecordID

'if a matching record was found, then move to it
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

End Function

'~~~~~~~~~~~~~~~~~~~~
where
- SomeID is the Name of the primary key field, which is in the RecordSource of the form -- assuming your primary key is a Long Integer data type (autonumbers are long integers)

Remember that the Rowsource for a combo can come from anywhere -- it can pull from multiple tables or only use one ... just make sure that the first column is the primary key ID of the table you want to search (and that field is part of the RecordSource for the form you are searching).


Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*




Tori wrote:
Good afternoon.

Okay, I think I am on the right track now - thankyouverymuch. However, because my customer name is now an unbounded data field, when I scroll through the database using the navigational buttons, it is not updating the customer name but it is updating the other fields.

For instance, I select "Atlas" and all the fields populate properly. If I want to see the record after Atlas and use the navigational buttons, "Atlas" remains the name in the customer field while all of the other fields continue to populate properly.

If I use the drop down for my record selection and do not use the navigational buttons, all the fields are populating properly.

I have a filter for "Open Date." The filter seems to be working properly, but when I use the navigational buttons, the name is not updating. You cannot use the drop down for this filter because you do not know what the next customer record is, which is why you had to use the filter. Did I lose you?

Any other suggestions?

"strive4peace" wrote:

Corrine and Tori,

oh, hey, I totally forgot about this...

for a form where you do not want to allow changes to the data, make the form RecordsetType --> Snapshot

that way, you do not have to deal with Locked or Enabled for the controls -- just leave them set to the defaults

you will be able to change anything that is not bound to the underlying RecordSource, such as a 'find combo'

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*




strive4peace wrote:
Hi Corrine,

make sure that, for the combo:

Locked --> No (False)
Enabled --> Yes (True)

this is opposite of what it should be for your data controls

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*




Corrine wrote:
Now the dropdown won't open at all.

"strive4peace" wrote:

Hi Corrine,

"The dropdown list will open, but I cannot select anything from the > list. This form needs to be only for running searches, not for editing in any way."

My guess is that you have the form AllowEdits property set to False

If you want the user to be able to edit the search combo, instead do this:

for each control, set:
Locked = True
and. optionally,
Enabled = False

and set AllowEdits = True for the form

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*




Corrine wrote:
I have a form with a dropdown list from which I want to be able to select an item and have the rest of the form populate additional fields with that record's information. Preferrably the form will start out blank. Currently it is automatically populating with the first record and is only letting me use the navigation buttons (at the bottom of my form) to move from record to record. The dropdown list will open, but I cannot select anything from the list. This form needs to be only for running searches, not for editing in any way. Suggestions? I'm working in Access '07.
.