469,087 Members | 1,284 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,087 developers. It's quick & easy.

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.
Jul 17 '05 #1
2 1659
Have you tried aliasing the field? "Select a.TrackNum as Track_1,
b.TrackNum as Track_2..."?

David

"Rowland Banks" <ba*****@hotmail.com> wrote in message news:<cd**********@sparta.btinternet.com>...
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.

Jul 17 '05 #2
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" <dh*******@chestnut.org> wrote in message
news:83**************************@posting.google.c om...
Have you tried aliasing the field? "Select a.TrackNum as Track_1,
b.TrackNum as Track_2..."?

David

"Rowland Banks" <ba*****@hotmail.com> wrote in message

news:<cd**********@sparta.btinternet.com>...
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.

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Jonathan Wood | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.