If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

DataComboBox - why does it keep screwing up my database??????????

HELP!!! I have a datacombo box that is connected to one data source and several
text boxes that are connected to another data source. When I select a new
name from the combo, the new data shows up no problem in the text boxes.
My problem is that when I exit the program, if I leave any other selection
showing other than the first name in the combo box, it changes my database
and erases the first name in the combo box and replaces it with the last
name selected. For example, if "John Doe" is the first name and "Jim Smith"
is the second, and I leave the combo selection on "Jim Smith", when I exit
the program, my database now has 2 records that have "Jim Smith" as the name
field. However, all of the other data (address, phone, etc) is still correct
for "John Doe." Does anyone know what I should do to prevent an update to
this particular data source?

Re: DataComboBox - why does it keep screwing up my database??????????

I'm not sure, but the datacombo box saves the data; you properly have the
tabel with the names as the row & list source - as you should - but also
as the databound.
Hopes it helps!

"Erin" <emw100@home.com> wrote:
>
>HELP!!! I have a datacombo box that is connected to one data source and
several
>text boxes that are connected to another data source. When I select a new
>name from the combo, the new data shows up no problem in the text boxes.
> My problem is that when I exit the program, if I leave any other selection
>showing other than the first name in the combo box, it changes my database
>and erases the first name in the combo box and replaces it with the last
>name selected. For example, if "John Doe" is the first name and "Jim Smith"
>is the second, and I leave the combo selection on "Jim Smith", when I exit
>the program, my database now has 2 records that have "Jim Smith" as the
name
>field. However, all of the other data (address, phone, etc) is still correct
>for "John Doe." Does anyone know what I should do to prevent an update
to
>this particular data source?

Re: DataComboBox - why does it keep screwing up my database??????????

Erin,

Connecting your form directly to the database is something less than desirable,
mostly because it causes problems like those you are having. What will help
your situation is to create a data or business object and a DBMS object.
You use the DBMS object to do all the database access and the data/business
objects to house all the data. Your form then can use just the data/business
object.

According to several people out here(I, myself, do not have this text), a
good text that explains this concept as well as helping you work through
some examples is:

"Stefan McKinnon Edwards" <stefan_edwards@hotmail.com> wrote:
>
>I'm not sure, but the datacombo box saves the data; you properly have the
>tabel with the names as the row & list source - as you should - but also
>as the databound.
>Hopes it helps!
>
>"Erin" <emw100@home.com> wrote:
>>
>>HELP!!! I have a datacombo box that is connected to one data source and
>several
>>text boxes that are connected to another data source. When I select a
new
>>name from the combo, the new data shows up no problem in the text boxes.
>> My problem is that when I exit the program, if I leave any other selection
>>showing other than the first name in the combo box, it changes my database
>>and erases the first name in the combo box and replaces it with the last
>>name selected. For example, if "John Doe" is the first name and "Jim Smith"
>>is the second, and I leave the combo selection on "Jim Smith", when I exit
>>the program, my database now has 2 records that have "Jim Smith" as the
>name
>>field. However, all of the other data (address, phone, etc) is still correct
>>for "John Doe." Does anyone know what I should do to prevent an update
>to
>>this particular data source?
>

Re: DataComboBox - why does it keep screwing up my database??????????

Craig,
Thanks for the input, but I am just a beginner and this is a mock program
for a project. We have to stay within the parameters of what we know. I
was hoping that there was a simple answer to this annoying little problem!
Thanks for your reply, though.

Erin

"Craig Brown" <brown.c3@ing-afs.com> wrote:
>
>Erin,
>
>Connecting your form directly to the database is something less than desirable,
>mostly because it causes problems like those you are having. What will
help
>your situation is to create a data or business object and a DBMS object.
> You use the DBMS object to do all the database access and the data/business
>objects to house all the data. Your form then can use just the data/business
>object.
>
>According to several people out here(I, myself, do not have this text),
a
>good text that explains this concept as well as helping you work through
>some examples is:
>
>Visual Basic 6 Business Objects by Rockford Lhotka (WROX Press)
>ISBN 1-861001-07-X
>(See Arthur Wood's response to the shadow table, in this news group.)
>
>Craig Brown
>
>
>"Stefan McKinnon Edwards" <stefan_edwards@hotmail.com> wrote:
>>
>>I'm not sure, but the datacombo box saves the data; you properly have the
>>tabel with the names as the row & list source - as you should - but also
>>as the databound.
>>Hopes it helps!
>>
>>"Erin" <emw100@home.com> wrote:
>>>
>>>HELP!!! I have a datacombo box that is connected to one data source and
>>several
>>>text boxes that are connected to another data source. When I select a
>new
>>>name from the combo, the new data shows up no problem in the text boxes.
>>> My problem is that when I exit the program, if I leave any other selection
>>>showing other than the first name in the combo box, it changes my database
>>>and erases the first name in the combo box and replaces it with the last
>>>name selected. For example, if "John Doe" is the first name and "Jim
Smith"
>>>is the second, and I leave the combo selection on "Jim Smith", when I
exit
>>>the program, my database now has 2 records that have "Jim Smith" as the
>>name
>>>field. However, all of the other data (address, phone, etc) is still
correct
>>>for "John Doe." Does anyone know what I should do to prevent an update
>>to
>>>this particular data source?
>>
>

Re: DataComboBox - why does it keep screwing up my database??????????

Erin,

While this does appear complex at first, it is, actually, a much simpler
approach. Instead of one giant form module that 'does everything', you have
3 much smaller modules that only do one thing, each.

You have a form, its job is to present and accept data to/from the user.
That's all it does.

You have a data object, its job is to keep all its data in sync, i.e. make
sure that all updates are accurate and all of them happen. This is, actually,
the most complex piece of the whole thing, as you have already discovered.

You have a DBMS object, its job is to get data from the database or put data
in the database. That's all it does.

I suspect that you already have something of a user interface built. So,
copy it over into a new project. Get rid of all the database stuff.

Now, build a database access module or, better yet, a class module that just
does the SQL stuff. Make sure you open and close your connection when the
object is created and destroyed.

Okay, now you have both ends of your project. What you need is a way to
make them 'talk to each other'. Build yourself another class module that
has all the data properties your form needs. Give it some things to do,
like, RefreshData or UpdateDB. When your form "calls" these subroutines
or functions, they in turn, communicate with the database object. Your database
object gets or puts information in the data object. It uses the information
in the data object to figure out what it should do, e.g. RefreshData would
populate a field in the database object that becomes the value of a Where
clause. Then it would call the database objects GetData method(function/subroutine).
This will keep the data on your form accurate and up to date.

If you start off small, by picking the easiest, most straightforward thing
to do and then build on it, you will find that this approach is far easier
than most others. Keeping your programs small and limiting them to doing
just one thing makes them 1) easier to write, 2) easier to debug, 3) easier
to change, and 4) easier to clone for something new. We are all very reluctant
to "start over", especially when we have a lot invested in a particular project.
Sometimes, it's better to just, start over. Only experience will tell you
where that point is...

Craig Brown

"Erin" <emw100@home.com> wrote:
>
>Craig,
>Thanks for the input, but I am just a beginner and this is a mock program
>for a project. We have to stay within the parameters of what we know.
I
>was hoping that there was a simple answer to this annoying little problem!
> Thanks for your reply, though.
>
>Erin
>
>"Craig Brown" <brown.c3@ing-afs.com> wrote:
>>
>>Erin,
>>
>>Connecting your form directly to the database is something less than desirable,
>>mostly because it causes problems like those you are having. What will
>help
>>your situation is to create a data or business object and a DBMS object.
>> You use the DBMS object to do all the database access and the data/business
>>objects to house all the data. Your form then can use just the data/business
>>object.
>>
>>According to several people out here(I, myself, do not have this text),
>a
>>good text that explains this concept as well as helping you work through
>>some examples is:
>>
>>Visual Basic 6 Business Objects by Rockford Lhotka (WROX Press)
>>ISBN 1-861001-07-X
>>(See Arthur Wood's response to the shadow table, in this news group.)
>>
>>Craig Brown
>>
>>
>>"Stefan McKinnon Edwards" <stefan_edwards@hotmail.com> wrote:
>>>
>>>I'm not sure, but the datacombo box saves the data; you properly have
the
>>>tabel with the names as the row & list source - as you should - but also
>>>as the databound.
>>>Hopes it helps!
>>>
>>>"Erin" <emw100@home.com> wrote:
>>>>
>>>>HELP!!! I have a datacombo box that is connected to one data source
and
>>>several
>>>>text boxes that are connected to another data source. When I select
a
>>new
>>>>name from the combo, the new data shows up no problem in the text boxes.
>>>> My problem is that when I exit the program, if I leave any other selection
>>>>showing other than the first name in the combo box, it changes my database
>>>>and erases the first name in the combo box and replaces it with the last
>>>>name selected. For example, if "John Doe" is the first name and "Jim
>Smith"
>>>>is the second, and I leave the combo selection on "Jim Smith", when I
>exit
>>>>the program, my database now has 2 records that have "Jim Smith" as the
>>>name
>>>>field. However, all of the other data (address, phone, etc) is still
>correct
>>>>for "John Doe." Does anyone know what I should do to prevent an update
>>>to
>>>>this particular data source?
>>>
>>
>

Re: DataComboBox - why does it keep screwing up my database??????????

I have limited experiance with bound data controls in VB, but I think your
problem is that you have the BoundColumn Property is set and it shouldn't
be. (I may have the wrong property name because I haven't worked with the
DataCombo much, but there is one property that sets were the data is pulled
from and one that will set what data you want changed. If you don't want to
change any of the data you wouldn't set that property to anything.)

Sue

"Erin" <emw100@home.com> wrote in message news:3aae59a1$1@news.devx.com...
>
> HELP!!! I have a datacombo box that is connected to one data source and
several
> text boxes that are connected to another data source. When I select a new
> name from the combo, the new data shows up no problem in the text boxes.
> My problem is that when I exit the program, if I leave any other
selection
> showing other than the first name in the combo box, it changes my database
> and erases the first name in the combo box and replaces it with the last
> name selected. For example, if "John Doe" is the first name and "Jim
Smith"
> is the second, and I leave the combo selection on "Jim Smith", when I exit
> the program, my database now has 2 records that have "Jim Smith" as the
name
> field. However, all of the other data (address, phone, etc) is still
correct
> for "John Doe." Does anyone know what I should do to prevent an update to
> this particular data source?

Re: DataComboBox - why does it keep screwing up my database??????????

Craig and Sue,
Thank you both very much for your intuitive replies.

Craig, I like your explanation; it doesn't sound so daunting now.
I will keep this in mind for future projects. However, I have a grade that
depends alot on following instructions, so I don't think I will be able to
use your solution this time.
I appreciate the time you took to write.

Sue, I think you may be onto something. I will try it.

Consequently, if anyone else has any input on this subject, PLEASE let me
know. Thanks!

Erin"Sue Harsevoort" <SusannaH67@hotmail.com> wrote:
>I have limited experiance with bound data controls in VB, but I think your
>problem is that you have the BoundColumn Property is set and it shouldn't
>be. (I may have the wrong property name because I haven't worked with the
>DataCombo much, but there is one property that sets were the data is pulled
>from and one that will set what data you want changed. If you don't want
to
>change any of the data you wouldn't set that property to anything.)
>
>Sue
>
>"Erin" <emw100@home.com> wrote in message news:3aae59a1$1@news.devx.com...
>>
>> HELP!!! I have a datacombo box that is connected to one data source and
>several
>> text boxes that are connected to another data source. When I select a
new
>> name from the combo, the new data shows up no problem in the text boxes.
>> My problem is that when I exit the program, if I leave any other
>selection
>> showing other than the first name in the combo box, it changes my database
>> and erases the first name in the combo box and replaces it with the last
>> name selected. For example, if "John Doe" is the first name and "Jim
>Smith"
>> is the second, and I leave the combo selection on "Jim Smith", when I
exit
>> the program, my database now has 2 records that have "Jim Smith" as the
>name
>> field. However, all of the other data (address, phone, etc) is still
>correct
>> for "John Doe." Does anyone know what I should do to prevent an update
to
>> this particular data source?
>
>