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.
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.