+ Reply to Thread
Results 1 to 2 of 2

Finding Column Letters

  1. #1
    Geoff
    Guest

    Finding Column Letters

    On opening a form, 6 txtboxes are populated with column letters IF a field
    name is found in data with a variable number of columns and field names in
    varying order.

    This code seemed to work fine but not always
    Sub FindCols()
    On Error Resume Next
    txtFax.Text = Split(Rows(1).Find("Fax").Address, "$")(1)
    txtSalut.Text = Split(Rows(1).Find("Salutation").Address, "$")(1)
    txtFirstName.Text = Split(Rows(1).Find("FirstName").Address, "$")(1)
    txtLastName.Text = Split(Rows(1).Find("LastName").Address, "$")(1)
    txtJob.Text = Split(Rows(1).Find("Job").Address, "$")(1)
    txtCompany.Text = Split(Rows(1).Find("Company").Address, "$")(1)
    On Error GoTo 0
    End Sub

    yields:
    txtFax = AB
    txtSalut = ""
    txtFirstName = ""
    txtLastName = M
    txtJob = A
    txtCompany = CA

    with this data
    A M AB CA
    Job LastName Fax Company

    but with this data
    A C M AB CA
    Job Christian Name LastName Fax Company

    yields:
    txtFax = AB
    txtSalut = ""
    txtFirstName = ""
    txtLastName = M
    txtJob = A
    txtCompany = C NOT CA ***********************

    Find appears to search for capitals and not whole words?
    How should my code be amended to make this work?

    Geoff


  2. #2
    Geoff
    Guest

    RE: Finding Column Letters

    So sorryyyyyyyy to waste time.
    The code does work correctly. In testing I had failed to remove the
    previous results from the txtboxes and the rest was sheer coincidence.
    dohhh, shame

    Geoff

    "Geoff" wrote:

    > On opening a form, 6 txtboxes are populated with column letters IF a field
    > name is found in data with a variable number of columns and field names in
    > varying order.
    >
    > This code seemed to work fine but not always
    > Sub FindCols()
    > On Error Resume Next
    > txtFax.Text = Split(Rows(1).Find("Fax").Address, "$")(1)
    > txtSalut.Text = Split(Rows(1).Find("Salutation").Address, "$")(1)
    > txtFirstName.Text = Split(Rows(1).Find("FirstName").Address, "$")(1)
    > txtLastName.Text = Split(Rows(1).Find("LastName").Address, "$")(1)
    > txtJob.Text = Split(Rows(1).Find("Job").Address, "$")(1)
    > txtCompany.Text = Split(Rows(1).Find("Company").Address, "$")(1)
    > On Error GoTo 0
    > End Sub
    >
    > yields:
    > txtFax = AB
    > txtSalut = ""
    > txtFirstName = ""
    > txtLastName = M
    > txtJob = A
    > txtCompany = CA
    >
    > with this data
    > A M AB CA
    > Job LastName Fax Company
    >
    > but with this data
    > A C M AB CA
    > Job Christian Name LastName Fax Company
    >
    > yields:
    > txtFax = AB
    > txtSalut = ""
    > txtFirstName = ""
    > txtLastName = M
    > txtJob = A
    > txtCompany = C NOT CA ***********************
    >
    > Find appears to search for capitals and not whole words?
    > How should my code be amended to make this work?
    >
    > Geoff
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1