Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select reocords from 4 combo boxes for a form

Status
Not open for further replies.

rmtiptoes

IS-IT--Management
Mar 30, 2004
55
US
I know that this is not hard but I am having some problems. I have a form that the users want to use multiple combo boxes to select the records.

If I select the ID number from the combo box, all of the filds populate except the PO NUmber. If I select the PO from the combo box, only the PO field gets populated. Why won't this link all?

I used the following code to search and select on ID and PurchOrder Number:

Private Sub IDNumber_AfterUpdate()
Me![IDNumber] = Me![PONumber]
Call FindAsset
End Sub

Private Sub IDNumber_GotFocus()
DoCmd.RunCommand acCmdSaveRecord
Me![IDNumber].Requery
End Sub

Private Sub PONumber_GotFocus()
DoCmd.RunCommand acCmdSaveRecord
Me![PONumber].Requery
End Sub

Private Sub PONumber_AfterUpdate()
Me![MylanAssetIDNumber] = Me![PONumber]
Call FindAsset
End Sub

'I commented this out cause it performs the same way
'Public Function FindAsset()
' Me.Filter = "[ID Number]='" & Me![IDNumber] & "'"
' Me.FilterOn = True
'End Function

Public Function FindAsset()
Dim lngTemp As Long

lngTemp = Me![IDNumber]

' Note: Requery triggers the Current event,
' where combo boxes values are reset.
' Hence, store the combo box value in a temp field and
' refresh combo box value after requery

Me.Requery 'To avoid bookmark bug problem
Me![IDNumber] = lngTemp
Me![PONumber] = lngTemp

Me.RecordsetClone.FindFirst "[ID Number] = '" & Me![IDNumber] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
End Function


Homer: But every time I learn something new, it pushes out something old! Remember that time I took a home wine-making course and forgot how to drive?
Marge Simpson: That's because you were drunk!
Homer: And how.

 
rmtiptoes,

I don't understand how IDNumber is supposed to work. Looks like as soon as the user makes a selection, it immediately resets it to the value of PONumber. Is that what you want? Can you provide some more info on how the combos are populated?

FWIW, it looks like you are using an expansion of the "Find a record on my form..." combo idea, such that users have multiple criteria from which to choose - with multiple combos. One technique that has worked well for me is to use a single combo, but use an option group to select the criteria for the search. Then in the AfterUpdate event of the option group, the row source for the combo is changed to reflect the search criteria. Let me know if you'd like to pursue that idea.

HTH,

Ken S.
 
Howdy Eupher . . . . .

Same duplicate/realitive content here: thread702-1063062

Calvin.gif
See Ya! . . . . . .
 
Ooops, I sorry. I thought I was attacking the problem piecemeal. Thanks for correcting me!

Homer: But every time I learn something new, it pushes out something old! Remember that time I took a home wine-making course and forgot how to drive?
Marge Simpson: That's because you were drunk!
Homer: And how.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top