Database search

Hi there,

I am new to VB Express. I have a project that requires finding 2 fields in a mdb database. The search key is a variant rather than a text box.

In the project I modify input from a text box. The resulted variant is the search key for retrieving 2 fields in the variant record.

The database is structured as follows:

Location Identifier Field1 Field2

Alocation ABC 123 456

Blocation DEF 789 987

Clocation GHI 654 321

The search key is the identifier variant which is processed from a text field.

I watched the tutorial but they automatically associate database from a text field rather than a variant.

Can any one suggest how to retrieve Field1 and Field two with the Identifier variant as key

I hope that my question is clear. Any help will be appreciated.

Joe



Answer this question

Database search

  • Adamx

    There is not datatype as variant. That's VB6 and VBA.

    Although vb6 had object datatypes it also had variant which was pretty much like an object.



  • Malleyo

    I take it that the example is contrived, in that there's no reason for this example not to use a string as the identifier. What's the type of the object in Access Access has a number of types, which map to SQL types, but I don't see variant as one of them



  • Antoine64

    Thanks to all who took the time to respond. I may have to be more specific about what I'm trying to do. I may have used the wrong terms and I apologize for it.

    The user, on my form, enters up to five identifier values. Because of various reasons I need to modify the user entries so I have 5 modified values aprt1 .... aprt5.

    These are my search keys and I need to find the values for Field1 and Field2 the correspond to the key. Rather than displaying Field1 and Field2, I need to perform computaions with the retrived values.

    I am going away for 9 days, but I'd apprciate any suggestions.

    Thanks again

    Joe Manor

    Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click

    Dim CustLine, AddLine, CityLine, PhoneLine, FaxLine, EmailLine

    Dim apt1, apt2, apt3, apt4, apt5, aprt1, aprt2, aprt3, aprt4, aprt5

    ' CustLine = CustomerName01.Text

    ' AddLine = Address01.Text

    ' CityLine = CityStateZip01.Text

    ' PhoneLine = Phone01.Text

    ' FaxLine = Fax01.Text

    ' EmailLine = Email01.Text

    apt1 = Airport01.Text ' Form input

    aprt1 = PrepID(apt1) ' Modify Function

    apt2 = Airport02.Text

    aprt2 = PrepID(apt2)

    apt3 = Airport03.Text

    aprt3 = PrepID(apt3)

    apt4 = Airport04.Text

    aprt4 = PrepID(apt4)

    apt5 = Airport05.Text

    aprt5 = PrepID(apt5)

    End Sub

    Private Function PrepID(ByVal Ident)

    Dim Tempo

    Tempo = UCase(Trim(Ident))

    If Mid(Tempo, 1, 1) <> "C" Then

    If Mid(Tempo, 1, 1) = "K" Then

    Tempo = "'" & Mid(Tempo, 2, 3)

    Else

    Tempo = "'" & Mid(Tempo, 1, 3)

    End If

    End If

    PrepID = Tempo

    End Function


  • chenwen

    I do a lot of access programming and this looks really didfferent to me.

    Location Identifier Field1 Field2

    Alocation ABC 123 456

    Blocation DEF 789 987

    Clocation GHI 654 321

    All of these are fields having different datatypes.

    The first are strings.....

    in ADO.Net this is called a TABLE with consists of horizontal rows and vertical colums.

    There are lots of ways to reference these values. Let us consider arbitrarilty the 780 in Row 1 Column 1.

    One way to do it is like this:

    Dim a as integer = table.rows(1).item(1)

    Or

    dim row as datarow = table.rows(1)

    dim a as integer = row(1) or

    dim a as integer = row("Field1")

    For loops look like this:

    dim a as integer

    For each row as datarow in tables.rows

    if row(1) = 789 then a = row(2)

    Next



  • Michael ADDS

    Dot Net doesn't have a variant datatype



  • craig_munday28

    I know what a variant is in VB6. I'm wondering what it is inside the database.



  • Database search