Updating textbox via code not updating recordset
Author |
Message |
Leon #1 / 11
|
 Updating textbox via code not updating recordset
Why don't you write changed text directly into recordset field?
Quote: > Lo gang, > This problem has been plaguing me for ages and i just cant solve it... > I have a textbox linked to a Recordset using the Datasouce & DataField > properties. When i manually enter a value in the field, the recordet is > updated to show the changes made. > THE PROBLEM > ============ > When i try to change this textbox via code... > e.g. me.txtCODE = "D001" > the recordset is not updated. > Can somone please tell me what i can do to get this to work via code. > Cheers, > Wayne
|
Mon, 24 Mar 2003 03:00:00 GMT |
|
 |
Toby Basc #2 / 11
|
 Updating textbox via code not updating recordset
Have you tried Me.txtCode.Text = "D001" oRecSet.Update Regards, -Toby Quote:
>Lo gang, >This problem has been plaguing me for ages and i just cant solve it... >I have a textbox linked to a Recordset using the Datasouce & DataField >properties. When i manually enter a value in the field, the recordet is >updated to show the changes made. >THE PROBLEM >============ >When i try to change this textbox via code... >e.g. me.txtCODE = "D001" >the recordset is not updated. >Can somone please tell me what i can do to get this to work via code. >Cheers, >Wayne
|
Mon, 24 Mar 2003 03:00:00 GMT |
|
 |
Bob Jenki #3 / 11
|
 Updating textbox via code not updating recordset
When i try and do a rsRecordset("Field") = "D001" I get an error saying that the data has changed... I think this is due to the fact, that the field is bound to the datafield in the recordset. As i said, if you manually change the field, the recordset is updated.. If you do it via code, the recordset is not updated... Anyone else care for a solution, Cheers, Wayne
Quote: > Why don't you write changed text directly into recordset field?
> > Lo gang, > > This problem has been plaguing me for ages and i just cant solve it... > > I have a textbox linked to a Recordset using the Datasouce & DataField > > properties. When i manually enter a value in the field, the recordet is > > updated to show the changes made. > > THE PROBLEM > > ============ > > When i try to change this textbox via code... > > e.g. me.txtCODE = "D001" > > the recordset is not updated. > > Can somone please tell me what i can do to get this to work via code. > > Cheers, > > Wayne
|
Mon, 24 Mar 2003 03:00:00 GMT |
|
 |
Bob Jenki #4 / 11
|
 Updating textbox via code not updating recordset
Yes i have tried updating the recordset... FYI - oRecSet.Update <--- updates the data on the database, not the recordset itself... Cheers, Wayne
Quote: > Have you tried > Me.txtCode.Text = "D001" > oRecSet.Update > Regards, > -Toby
> >Lo gang, > >This problem has been plaguing me for ages and i just cant solve it... > >I have a textbox linked to a Recordset using the Datasouce & DataField > >properties. When i manually enter a value in the field, the recordet is > >updated to show the changes made. > >THE PROBLEM > >============ > >When i try to change this textbox via code... > >e.g. me.txtCODE = "D001" > >the recordset is not updated. > >Can somone please tell me what i can do to get this to work via code. > >Cheers, > >Wayne
|
Mon, 24 Mar 2003 03:00:00 GMT |
|
 |
Toby Basc #5 / 11
|
 Updating textbox via code not updating recordset
Oops! I thought we were speaking ADO, not DAO. I now recall that with ADO the way you make a change "stick" is by calling the Move method, not the Update method. My test with ADO showed that you can do a "RecSet.Move 0" (zero). Although the record pointer is not moved at all, the record IS updated. Saves a line of code as well. If, indeed, you are using DAO, have you tried "rs.Move 0"? Regards, -Toby Quote:
>Thanks for ure help... weirdly thats what i have just been looking at :) >But its pleasing to see someone on the same lines as myself. Anyway what i >did was:- >me.txtcode.text = "D001" >rs.movenext >rs.moveprevious >This works... >Where as >me.txtcode.text = "D001" >rs.update >Doesnt! >This is very strange, and would have thought that the update is the correct >way to update the database :) >I will use the method outlined, but i would like an EXPERT DAO programmer >his/her opinions on this? Solutions? Reason why? Is this a bug or a >feature :) >Cheers, >Wayne
>> This seems to work on my PC >> Me.txtCode.Text = "D001" >> oRecSet.Move 0 >> Can this be the end of the age-long plague? >> Regards, >> -Toby
>> >Yes i have tried updating the recordset... >> >FYI - oRecSet.Update <--- updates the data on the database, not the >> >recordset itself... >> >Cheers, >> >Wayne
>> >> Have you tried >> >> Me.txtCode.Text = "D001" >> >> oRecSet.Update >> >> Regards, >> >> -Toby
>> >> >Lo gang, >> >> >This problem has been plaguing me for ages and i just cant solve it... >> >> >I have a textbox linked to a Recordset using the Datasouce & DataField >> >> >properties. When i manually enter a value in the field, the recordet >is >> >> >updated to show the changes made. >> >> >THE PROBLEM >> >> >============ >> >> >When i try to change this textbox via code... >> >> >e.g. me.txtCODE = "D001" >> >> >the recordset is not updated. >> >> >Can somone please tell me what i can do to get this to work via code. >> >> >Cheers, >> >> >Wayne
|
Mon, 24 Mar 2003 03:00:00 GMT |
|
 |
Bob Jenki #6 / 11
|
 Updating textbox via code not updating recordset
OOOps... I did mean ADO:)
Quote: > Oops! I thought we were speaking ADO, not DAO. I now recall that with ADO the way > you make a change "stick" is by calling the Move method, not the Update method. My > test with ADO showed that you can do a "RecSet.Move 0" (zero). Although the record > pointer is not moved at all, the record IS updated. Saves a line of code as well. If, > indeed, you are using DAO, have you tried "rs.Move 0"? > Regards, > -Toby
> >Thanks for ure help... weirdly thats what i have just been looking at :) > >But its pleasing to see someone on the same lines as myself. Anyway what i > >did was:- > >me.txtcode.text = "D001" > >rs.movenext > >rs.moveprevious > >This works... > >Where as > >me.txtcode.text = "D001" > >rs.update > >Doesnt! > >This is very strange, and would have thought that the update is the correct > >way to update the database :) > >I will use the method outlined, but i would like an EXPERT DAO programmer > >his/her opinions on this? Solutions? Reason why? Is this a bug or a > >feature :) > >Cheers, > >Wayne
> >> This seems to work on my PC > >> Me.txtCode.Text = "D001" > >> oRecSet.Move 0 > >> Can this be the end of the age-long plague? > >> Regards, > >> -Toby
> >> >Yes i have tried updating the recordset... > >> >FYI - oRecSet.Update <--- updates the data on the database, not the > >> >recordset itself... > >> >Cheers, > >> >Wayne
> >> >> Have you tried > >> >> Me.txtCode.Text = "D001" > >> >> oRecSet.Update > >> >> Regards, > >> >> -Toby
> >> >> >Lo gang, > >> >> >This problem has been plaguing me for ages and i just cant solve it... > >> >> >I have a textbox linked to a Recordset using the Datasouce & DataField > >> >> >properties. When i manually enter a value in the field, the recordet > >is > >> >> >updated to show the changes made. > >> >> >THE PROBLEM > >> >> >============ > >> >> >When i try to change this textbox via code... > >> >> >e.g. me.txtCODE = "D001" > >> >> >the recordset is not updated. > >> >> >Can somone please tell me what i can do to get this to work via code. > >> >> >Cheers, > >> >> >Wayne
|
Mon, 24 Mar 2003 03:00:00 GMT |
|
 |
Vorte #7 / 11
|
 Updating textbox via code not updating recordset
Personally having 6 months of playing with VB and ADO I say that the best method is no databound controls and no dataenvironment . Do everything manually and save yourself later headaches !!! Regards VOrtex
Quote: > Lo gang, > This problem has been plaguing me for ages and i just cant solve it... > I have a textbox linked to a Recordset using the Datasouce & DataField > properties. When i manually enter a value in the field, the recordet is > updated to show the changes made. > THE PROBLEM > ============ > When i try to change this textbox via code... > e.g. me.txtCODE = "D001" > the recordset is not updated. > Can somone please tell me what i can do to get this to work via code. > Cheers, > Wayne
|
Tue, 25 Mar 2003 03:00:00 GMT |
|
 |
Bob Jenki #8 / 11
|
 Updating textbox via code not updating recordset
So what you are saying is to bind every data to control i.e formload me.txtCode = rs("Code") formclose rs("Code") = me.txtCode 1. This is very longwinded 2. Makes the code highly unreadable 3. If changes have to be made, makes it very complicated. To me this is crap, when u are able to bind that data to the recordset and then do an update or cancel... Cheers, Wayne
Quote: > Personally having 6 months of playing with VB > and ADO > I say that the best method is no databound controls > and no dataenvironment . > Do everything manually and save yourself later headaches !!! > Regards > VOrtex
> > Lo gang, > > This problem has been plaguing me for ages and i just cant solve it... > > I have a textbox linked to a Recordset using the Datasouce & DataField > > properties. When i manually enter a value in the field, the recordet is > > updated to show the changes made. > > THE PROBLEM > > ============ > > When i try to change this textbox via code... > > e.g. me.txtCODE = "D001" > > the recordset is not updated. > > Can somone please tell me what i can do to get this to work via code. > > Cheers, > > Wayne
|
Tue, 25 Mar 2003 03:00:00 GMT |
|
 |
Vorte #9 / 11
|
 Updating textbox via code not updating recordset
Depends how you attack the problem !!! Tell me .... with a databound textbox don't you have to get the control set the datasource and the datafield ??? Look at my Code Sub BindTextBox(RecSet As ADODB.Recordset, TextBox As TextBox, Field As String) If Not IsNull(RecSet.Fields(Field)) Then TextBox.Text = RecSet.Fields(Field) Else TextBox.Text = "" End If End Sub And to call it I need only set the control and the field Private Sub BindCompany(RecSet As ADODB.Recordset) BindTextBox RecSet, Text1(0), "txtCode" End Sub Therefore mine is I think quicker to write, quicker to load the fields and bug free and reliable and totally under MY CONTROL!!! Also changing if anything is simple!!! Regards VOrtex p.s Tell me when you get wise and get everthing under your control
Quote: > So what you are saying is to bind every data to control > i.e > formload > me.txtCode = rs("Code") > formclose > rs("Code") = me.txtCode > 1. This is very longwinded > 2. Makes the code highly unreadable > 3. If changes have to be made, makes it very complicated. > To me this is crap, when u are able to bind that data to the recordset and > then do an update or cancel... > Cheers, > Wayne
> > Personally having 6 months of playing with VB > > and ADO > > I say that the best method is no databound controls > > and no dataenvironment . > > Do everything manually and save yourself later headaches !!! > > Regards > > VOrtex
> > > Lo gang, > > > This problem has been plaguing me for ages and i just cant solve it... > > > I have a textbox linked to a Recordset using the Datasouce & DataField > > > properties. When i manually enter a value in the field, the recordet is > > > updated to show the changes made. > > > THE PROBLEM > > > ============ > > > When i try to change this textbox via code... > > > e.g. me.txtCODE = "D001" > > > the recordset is not updated. > > > Can somone please tell me what i can do to get this to work via code. > > > Cheers, > > > Wayne
|
Fri, 28 Mar 2003 03:00:00 GMT |
|
 |
Vorte #10 / 11
|
 Updating textbox via code not updating recordset
Sorry to add on this .... to save the new values CmdSave_Click UpdateCompany CompanyRSet CompanyRSet.Update End Sub Private Sub UpdateCompany(RecSet As ADODB.Recordset) UpdateTextBox RecSet, Text1(0), "txtCode" End Sub Sub UpdateTextBox(RecSet As ADODB.Recordset, TextBox As TextBox, Field As String) If TextBox.Text = "" Then RecSet.Fields(Field) = Null Else RecSet.Fields(Field) = TextBox.Text End If End Sub Though you might see it as longwinded , once you adopt this approach it is as easy as using databound recordsets, and you may think I am wrong but to me it is easier, runs faster and is error free at least so far. I can't say I ever get an update or binding error : ) And bear in mind you don't think I tried the other ways !!!! Regards VOrtex
Quote: > Depends how you attack the problem !!! > Tell me .... with a databound textbox don't you > have to get the control set the datasource and the datafield ??? > Look at my Code > Sub BindTextBox(RecSet As ADODB.Recordset, TextBox As TextBox, Field As > String) > If Not IsNull(RecSet.Fields(Field)) Then > TextBox.Text = RecSet.Fields(Field) > Else > TextBox.Text = "" > End If > End Sub > And to call it I need only set the control and the field > Private Sub BindCompany(RecSet As ADODB.Recordset) > BindTextBox RecSet, Text1(0), "txtCode" > End Sub > Therefore mine is I think quicker to write, quicker to > load the fields and bug free and reliable and totally > under MY CONTROL!!! > Also changing if anything is simple!!! > Regards > VOrtex > p.s Tell me when you get wise and get everthing under > your control
> > So what you are saying is to bind every data to control > > i.e > > formload > > me.txtCode = rs("Code") > > formclose > > rs("Code") = me.txtCode > > 1. This is very longwinded > > 2. Makes the code highly unreadable > > 3. If changes have to be made, makes it very complicated. > > To me this is crap, when u are able to bind that data to the recordset and > > then do an update or cancel... > > Cheers, > > Wayne
> > > Personally having 6 months of playing with VB > > > and ADO > > > I say that the best method is no databound controls > > > and no dataenvironment . > > > Do everything manually and save yourself later headaches !!! > > > Regards > > > VOrtex
> > > > Lo gang, > > > > This problem has been plaguing me for ages and i just cant solve it... > > > > I have a textbox linked to a Recordset using the Datasouce & DataField > > > > properties. When i manually enter a value in the field, the recordet > is > > > > updated to show the changes made. > > > > THE PROBLEM > > > > ============ > > > > When i try to change this textbox via code... > > > > e.g. me.txtCODE = "D001" > > > > the recordset is not updated. > > > > Can somone please tell me what i can do to get this to work via code. > > > > Cheers, > > > > Wayne
|
Fri, 28 Mar 2003 03:00:00 GMT |
|
 |
sanjeev sharm #11 / 11
|
 Updating textbox via code not updating recordset
Hi, According to Microsoft this bug been fixed with Visual Basic 6.0 SP3 and ADO 2.5. bye sanjeev
Quote: > Lo gang, > This problem has been plaguing me for ages and i just cant solve it... > I have a textbox linked to a Recordset using the Datasouce & DataField > properties. When i manually enter a value in the field, the recordet is > updated to show the changes made. > THE PROBLEM > ============ > When i try to change this textbox via code... > e.g. me.txtCODE = "D001" > the recordset is not updated. > Can somone please tell me what i can do to get this to work via code. > Cheers, > Wayne
|
Sat, 29 Mar 2003 03:00:00 GMT |
|
|
|