Look up records in a form

enllaw

Registered User.
Local time
Today, 02:04
Joined
Jun 27, 2003
Messages
12
I need a control that will look up an invoice record when the invoice number is keyed into the field. The form's record source is a table that has invoice #, amt, date, etc. When I put the invoice number into this field, I want the entire record to display. Can I do that?
 
Put a blank textbox on your form and name it txtfindbox. In the afterupdate event of the textbox (or you could put this in the OnClick of a command button) put this code:

Me.RecordsetClone.FindFirst "[INVOICEFIELDNAME] = '" & Me.txtfindbox & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
If Me.txtfindbox <> Me.INVOICEFIELDNAME Then
MsgBox "Seach item not found. Make sure to enter the Invoice ID as seen in the Invoice ID field at the top-left hand side of the form", vbCritical, "Search Error"
Me.txtfindbox = ""
Else
Me.txtfindbox = ""
End If

HTH,
Kev
 
Actually, I am looking up a voucher ID / business unit combo not an invoice number. Sorry. Do I just replace "invoicefieldname" with voucheridfieldname? When I try and do that, all the records show up in the form when they are added into the table and there is a record number on the bottom of the page. I want the form to look for the voucher id/business unit up for me, not already be in there. Does that make sense? I also want to add a box to put comments in from another table. Any help on that would be greatly appreciated. Thanks.
 
Last edited:
OK - This can be done without too much of a problem but I need some more info from you:

what is the name you use for the ID field:
what data type is the field: (string or numeric)

Kev
 
Look up records in a fom

The business unit is named BusUnit and the voucher ID is named txtfindbox. They are both numeric. The bus unit is 5 numbers and the voucher id is 8 in case you need to know.

Thank you!!
 
What exactly is business unit? Is it the tables primary key or is VoucherID the primary key?

Please explain, in as much detail as possible, what it is your trying to do as I think I'm missing what you want to do....

My interpretation as to what you are trying to do is this:

- User gets to a form where they are prompted to enter the VoucherID Number
- They enter the number and click a button
- They are transferred to the Voucher Form and take to the record that correspondes to the ID they requested


Is this right?

K
 
OK

On the table I'm using, there is no primary key. There are several tables. Daily is a list of vouchers (invoices) with problems. Master is a list of all vouchers past and present with problems. Daily is the one I'm using. I will need to be able to look up a voucher from the daily table and add a comment to it. The business unit is the division and every division has their own number to identify them. I'm in the HQ office and the divisions are the branches if you will. I only want one record to pull up at a time, then be able to update the comment field which is in the MasterLocal table. MasterLocal is just a copy of master so I can change it. After I am finished with the form for editing data, I need to build a report that will update all the daily vouchers. Confused now? I know I am.
 
Are these linked tables? Is this your DB (Your the owner/creator) or is this someone elses? The reason I ask is that if it is your db then I would highly recommend adding a primary key field as this is very important for keeping the intergrity of the data intact.

Next thing:

Do you have relationships setup for the tables? And if so how are they related? (This is important because if you are going to be updating I need to know how they relate to one another...)

Next thing:

Can you zip and attach your db to this thread so I can have a look and see if I can help you find a solution?

-K
 
DB

It was initially mine and someone else made changes to it. I don't know if they created a new one or built on the one I had. I can try to e-mail it to you if you want to give me your e-mail address or tell me how to do it from here. He made it very difficult for me to figure out what he was doing with it.
 
Last edited:
While you're waiting for Kevin_S to get back with you, may I suggest you search the Access help file for "autolookup query". That might be an option for you.
 
I got it

Kevin helped me with it. You're great Kevin, thanks for your help!!!!!
 
I an hoping to get a similiar problem to this fixed.

I'm trying to search records based on an afterupdate event on a text box.

I need a msg box to open giving the user the choice to view this record or to return to the form to input a nre invoice.

Can anyone halp please.
Thanks
 

Users who are viewing this thread

Back
Top Bottom