Re: Record Lookup
- From: MikeS <MikeS@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 11 Sep 2007 08:44:05 -0700
The Access file name is "ItemMaster.dbf"
The table name is "Itemlist"
The field names are "ID (primary), ITNBR, ITDSC, UCDEF"
This is the code that populates the combobox:
cboItemNum.DataSource = ItemMasterDataSet1.Tables("ItemList")
cboItemNum.DisplayMember = "ID"
The following is the code snippet I found to search the table:
Dim strItemNum As String
Dim drSelectedRecord As DataRow
strItemNum = cboItemNum.Text
drSelectedRecord = ItemMasterDataSet1.ItemList.Rows.Find(strItemNum)
Try
lblItemDesc2.Text = drSelectedRecord(1).ToString & _
" - " & drSelectedRecord(2).ToString
Catch ex As Exception
MsgBox("Record " & strItemNum & " was not found.")
End Try
The problem is I can only search by "ID" and I want to search by "ITNBR". I
have
tried changing the primary field and "DisplayMember" to "ITNBR". This will
change the field in my combo box but I get an error when I do the lookup.
Let me know if you need any additional information.
Thanks in advance.
Mike
"rowe_newsgroups" wrote:
On Sep 11, 9:18 am, MikeS <Mi...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:.
I have searched Google with every possible combination of key words I can
imagine and have not been able to find an answer to what I think is a very
simple question and probably has a very simple solution.
Keep in mind.....I am a NOVICE programmer, so you will have to spell it out
for me.
I am trying to write a very simple program in VB.Net 2005. that will search
a single Access database table and return the value of one field based on
criteria that I provide for any other field I choose. The only way I have
had any success is if I search by the primary key field, which does not give
me the versatility that I need.
Can anyone point me to some sample code that will help me accomplish this?
Thanks in advance.
Mike
You should connect with the OleDb database providers and then do the
search with a simple Sql query.
If you post a bit of the target table's schema (column names mainly)
and tell me which fields you need to search I'll be more than happy to
write up some simple code for you.
Thanks,
Seth Rowe
- Follow-Ups:
- Re: Record Lookup
- From: Patrice
- Re: Record Lookup
- References:
- Re: Record Lookup
- From: rowe_newsgroups
- Re: Record Lookup
- Prev by Date: Re: Start a method after form shown on screen
- Next by Date: Re: How do I: Query AD from a list of usernames in Excel
- Previous by thread: Re: Record Lookup
- Next by thread: Re: Record Lookup
- Index(es):