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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't get look-up to work!

Status
Not open for further replies.

osp001

Technical User
Nov 19, 2003
79
US
Go easy on me- I barely know any VB at all!

I'm trying to get a form to look up the information so that when I enter an item number, it'll go to another form and give me the information relevant to that number.

In short, it locks up on the "itemdata" part of the indicated line with a compiling error (Method or Data Member Not Found). I'm just trying to get to the data quickly, so that I can enter an AccessionNumber, and have it go to the correct frm_edit_seeds_sub3 form that corresponds with that number.

Help! Thanks in advance.

Private Sub AccessionQuickLookup_KeyPress(KeyAscii As Integer)
Dim stDocName As String
Dim intSeedID As Integer
Dim intSelected As Integer
Dim stLinkCriteria As String
Dim AccessionNumber As String

If KeyAscii = 13 Then
Me.Refresh
AccessionNumber = AccessionQuickLookup.Value
AccessionQuickLookup.Value = ""
---> intSeedID = Me.AccessionQuickLookup.ItemData(intSelected)
stDocName = "frm_edit_seeds_sub3"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.OpenForm "frm_edit_seeds_sub3", acNormal, , , , , intSeedID
End If



End Sub
 
Hi
I don't quite get it, but maybe:
[tt]intSeedID = AccessionQuickLookup
stDocName = "frm_edit_seeds_sub3"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.OpenForm "frm_edit_seeds_sub3", acNormal, ,"SeedID=" & intSeedID[/tt]

Assuming that AccessionQuickLookup is a Listbox.
 
I agree with Remou, What is AccessionQuickLookup ? If it is a Listbox ItemData doesn't return a value. I am not sure why you are opening the same form twice but as long as you mean to .... wonderful.

Joe
 
ospOO1, as Remou & Joe have said, but also,
it does appear ...
AccessionQuickLookup is a ListBox.
intSeedID is an integer.
intSelected is an integer and it equals 0.

So basically you want the value of the first record in the ListBox.(whatever the bound column is.)

BUT BECAUSE YOU CLEARED THE VALUE..
...AccessionQuickLookup.Value = ""

AccessionQuickLookup does not have an itemdata value, in other words, no selections have been made.

AAAAAND

AccessionNumber is a string, why is it not failing here?...

AccessionNumber = AccessionQuickLookup.Value

is your list box bound to a string value or integer?

...I'm sorry, you did say go easy on you(LOL).


oosp001, can you give us the sQL of the listbox and tell us which column is bound and what datatype it is.
That should be able direct us in what advice to give.

Good luck either way.




 
Okay- here's what I'm trying to do. I have a form (frm_main) with an unbound text box (AccessionQuickLookup) that I want to use so I can type in a number (AccNum), and have the relevant information for that number come up in the form frm_edit_seeds_sub3.

Is that enough information? :-/ Sorry to be such a dolt about this; the books I've been reading about VB aren't quite up to answering this for me.
 
Well then, this is the only line you need..


DoCmd.OpenForm "frm_edit_seeds_sub3", acNormal, ,"SeedID=" & AccessionQuickLookup


You can use this from the after update event of AccessionQuickLookup , or from a separate command button(preferable)

So, say you have a command button labeled "cmdOpenForm"...

Private Sub cmdOpenForm_Click()
DoCmd.OpenForm "frm_edit_seeds_sub3", acNormal, ,"SeedID=" & AccessionQuickLookup
End Sub

If I've understood correctly, this should suffice.
 
Zion7> That works great to open up the form, but only to the first entry.

The way I have it built from the main page is so that I can enter a given number (AccNum) and go directly to the relevant entry. So, if I want to look at AccNum 1234, I can just enter "1234" and go directly to that entry.

I'm just not sure how to get that number to transfer. :-/
 
1) textboxes don't have an ItemData property
2) if this is in the keydown event, every time you type a key you are going to trigger this code
3) is it that Zion7's suggestion only returned one record in the second form, while you want all of the records returned and to be taken to the particular one you referenced? if so, you can do a Find operation.
4) It really looks as if you are trying to re-program the wheel here... you are trying to mimic the action of subforms linked on Master and Child fields without having the second form contained in a control on the first form. Wouldn't a subform do what you want it to do, and would that or would it not be an option here, based on your requirements?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top