wlwebb
asked on
Access - Click on record on Subform to Select Main Form Item
Hello All
I have a Form with one subform. That subform is a continuous form where I list all Inventory Items in the system. My main form is to input or edit an individual Inventory Item.
(I didn't use a Listbox because I don't like the fact that I can't align individual list columns left, right or center - maybe you can and I just don't see a place to instruct it how to align)
So, on my Subform I have the primary key field [InvItemID] not visible. They can see the [InvItem] description along with some other fields. In the [InvItem] OnClick event I want it to select the main form's selected Inv Item.
I tried using
Private Sub InvItem_Click()
DoCmd.SearchForRecord , "frm_InvItem", acFirst, "[InvItem] = " & Str(Nz(Screen.ActiveContro l, 0))
End Sub
However I get a Type Mismatch.
I have a Form with one subform. That subform is a continuous form where I list all Inventory Items in the system. My main form is to input or edit an individual Inventory Item.
(I didn't use a Listbox because I don't like the fact that I can't align individual list columns left, right or center - maybe you can and I just don't see a place to instruct it how to align)
So, on my Subform I have the primary key field [InvItemID] not visible. They can see the [InvItem] description along with some other fields. In the [InvItem] OnClick event I want it to select the main form's selected Inv Item.
I tried using
Private Sub InvItem_Click()
DoCmd.SearchForRecord , "frm_InvItem", acFirst, "[InvItem] = " & Str(Nz(Screen.ActiveContro
End Sub
However I get a Type Mismatch.
Can you upload sample DB with your form and some dummy data?
I don't see how this bit is reliable.
"[InvItem] = " & Str(Nz(Screen.ActiveContro l, 0))
From what you say the user could be clicking on any of several fields and surely the InvItem field in the main form has to match the one corresponding field in the subform, not just any field.
But I think you would need...
"[InvItem] = '" & Str(Nz(Screen.ActiveContro l, 0)) & "'"
"[InvItem] = " & Str(Nz(Screen.ActiveContro
From what you say the user could be clicking on any of several fields and surely the InvItem field in the main form has to match the one corresponding field in the subform, not just any field.
But I think you would need...
"[InvItem] = '" & Str(Nz(Screen.ActiveContro
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
LSM thanks..
Peter.. I still got the Type Mismatch message
Peter.. I still got the Type Mismatch message