Bound control bug when two SQL fields have same name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rowland Banks

    #1

    Bound control bug when two SQL fields have same name

    Hi,

    I've got two fields in seperate SQL tables (a and b), both called trackNum.
    b.trackNum is a foriegn key into a.trackNum. I've got a form with a few
    bound controls on it (textboxes specifically), one of which displays the
    trackNum from the query "SELECT a.*, b.* FROM a, b WHERE a.trackNum =
    b.trackNum". All of the controls are displaying their data correctly except
    txtTrackNum, which is always displaying the digit 1. If I change my query so
    that it only selects trackNum from a everything is hunky-dory. Anyone come
    across this behaviour before?

    PS. I thought I could fix it by binding txtTrackNum to a.trackNum, rather
    than just trackNum, but then it complains it can't find that field.

    Thanks,

    Rowland.


  • David

    #2
    Re: Bound control bug when two SQL fields have same name

    Have you tried aliasing the field? "Select a.TrackNum as Track_1,
    b.TrackNum as Track_2..."?

    David

    "Rowland Banks" <banksr0@hotmai l.com> wrote in message news:<cd07tf$6c 8$1@sparta.btin ternet.com>...[color=blue]
    > Hi,
    >
    > I've got two fields in seperate SQL tables (a and b), both called trackNum.
    > b.trackNum is a foriegn key into a.trackNum. I've got a form with a few
    > bound controls on it (textboxes specifically), one of which displays the
    > trackNum from the query "SELECT a.*, b.* FROM a, b WHERE a.trackNum =
    > b.trackNum". All of the controls are displaying their data correctly except
    > txtTrackNum, which is always displaying the digit 1. If I change my query so
    > that it only selects trackNum from a everything is hunky-dory. Anyone come
    > across this behaviour before?
    >
    > PS. I thought I could fix it by binding txtTrackNum to a.trackNum, rather
    > than just trackNum, but then it complains it can't find that field.
    >
    > Thanks,
    >
    > Rowland.[/color]

    Comment

    • Rowland Banks

      #3
      Re: Bound control bug when two SQL fields have same name

      That works great, thanks. I ended up using SELECT a.*, b.field1, b.field2,
      etc. but I will definitely use your suggestion in future. I never knew you
      could alias fields as well as tables. Thanks.

      "David" <dhodgkins@ches tnut.org> wrote in message
      news:83b47ff1.0 407200845.32d6e af5@posting.goo gle.com...[color=blue]
      > Have you tried aliasing the field? "Select a.TrackNum as Track_1,
      > b.TrackNum as Track_2..."?
      >
      > David
      >
      > "Rowland Banks" <banksr0@hotmai l.com> wrote in message[/color]
      news:<cd07tf$6c 8$1@sparta.btin ternet.com>...[color=blue][color=green]
      > > Hi,
      > >
      > > I've got two fields in seperate SQL tables (a and b), both called[/color][/color]
      trackNum.[color=blue][color=green]
      > > b.trackNum is a foriegn key into a.trackNum. I've got a form with a few
      > > bound controls on it (textboxes specifically), one of which displays the
      > > trackNum from the query "SELECT a.*, b.* FROM a, b WHERE a.trackNum =
      > > b.trackNum". All of the controls are displaying their data correctly[/color][/color]
      except[color=blue][color=green]
      > > txtTrackNum, which is always displaying the digit 1. If I change my[/color][/color]
      query so[color=blue][color=green]
      > > that it only selects trackNum from a everything is hunky-dory. Anyone[/color][/color]
      come[color=blue][color=green]
      > > across this behaviour before?
      > >
      > > PS. I thought I could fix it by binding txtTrackNum to a.trackNum,[/color][/color]
      rather[color=blue][color=green]
      > > than just trackNum, but then it complains it can't find that field.
      > >
      > > Thanks,
      > >
      > > Rowland.[/color][/color]


      Comment

      Working...