PDA

Click to See Complete Forum and Search --> : RE:Help


yinyin
Jun 14th, 2000, 10:06 AM
Can anyone tell me how to update the record to the database. Well it only update the forst record but not the second one. My code is as follow: -

frmhistory.data3.recordset.edit
frmhistory.text2.text=text3.text frmhistory.data3.recordset.update

adodc2.recordset.movenext
if adodc2.recordset.eof = true then
command1.enabled=false
end if

well the purpose of the edir is to show only the specific record i choose which is then update to the db and then view the report.

Thank in advance if someone can help me :)

Jun 14th, 2000, 11:40 AM
What are you trying to update?????? What goes in text3???????, you need a Edit and Update for each record ya want updated

yinyin
Jun 14th, 2000, 11:49 AM
Originally posted by Jethro
What are you trying to update?????? What goes in text3???????, you need a Edit and Update for each record ya want updated

Well I need to update whatever I enter in text3 to the text2 in the frmhistory. Initially it want to update but only the first record.The second one it does not. I have the edit follow by update. The prob. now is that i cant update the second one. In my report it only show the first record i update and the previous record that i search. so any idea. Thanks in advance.

Jun 14th, 2000, 12:10 PM
Do
frmHistory.data3.Recordset.Edit
frmHistory.data3.Recordset!Text2 = "" & Text3
frmHistory.data3.Recordset.Update
frmHistory.data3.Recordset.MoveNext
If frmHistory.EOF Then Exit Do
Loop

"
" Will update from current record to EOF condition
"
Hope it helps. Try posting in General VB Forum for quicker answers.

Gen-X
Jun 14th, 2000, 12:45 PM
I think Text2 is a "data-aware" textbox and that every time she presses the "command1" button it puts the value she entered into Text3.text to the recordset based on the connected Text2 field and then moved to the next record so that it refreshed the contents of Text2 automatically.


frmhistory.data3.recordset.edit
frmhistory.text2.text=text3.text
frmhistory.data3.recordset.update

adodc2.recordset.movenext
if adodc2.recordset.eof = true then
command1.enabled=false
end if


I have to ask... where is command1 and text3 contained? Obviously they are not on the frmhistory form or else you would have stated them.

Doing it this way the only way you get to the next record is by pressing the command1 button which means it will DEFINATELY set the text2 to whatever you have in text3 each time you press this button...

yinyin
Jun 14th, 2000, 01:21 PM
Originally posted by Gen-X
I think Text2 is a "data-aware" textbox and that every time she presses the "command1" button it puts the value she entered into Text3.text to the recordset based on the connected Text2 field and then moved to the next record so that it refreshed the contents of Text2 automatically.


frmhistory.data3.recordset.edit
frmhistory.text2.text=text3.text
frmhistory.data3.recordset.update

adodc2.recordset.movenext
if adodc2.recordset.eof = true then
command1.enabled=false
end if


I have to ask... where is command1 and text3 contained? Obviously they are not on the frmhistory form or else you would have stated them.

Doing it this way the only way you get to the next record is by pressing the command1 button which means it will DEFINATELY set the text2 to whatever you have in text3 each time you press this button...


For Gen-X

Command1 and text3 are on the frmadjust. What u say is true. I think it just update whatever i enter in text3. So do u have any idea to update the record I search.

For jethro

well nope it doesnt work. It gave me an error. it say datamember no found in the line frmhistory.eof

hope to hear from u soon

Jun 14th, 2000, 01:28 PM
If frmHistory.EOF Then Exit Do

Should be

If frmHistory.Data3.Recordset.Eof Then Exit Do

But if you are data binding then don't use this approach, which is for non-data bound coding.

yinyin
Jun 14th, 2000, 02:27 PM
Originally posted by Jethro
If frmHistory.EOF Then Exit Do

Should be

If frmHistory.Data3.Recordset.Eof Then Exit Do

But if you are data binding then don't use this approach, which is for non-data bound coding.

Well it still dont work. an error occur at frmhistory.data3.recordset.edit. The error was no current record.

Maybe i should give you the full code. Have a look at it and feel free to give command or some changes. Thank in advance.

Code:

Private Sub Command1_Click()
Do
frmHistory.Data3.Recordset.Edit
frmHistory.Text13.Text = DataCombo1.Text
frmHistory.Text25.Text = Text1.Text
frmHistory.Text26.Text = Text2.Text
frmHistory.Text27.Text = Text3.Text
frmHistory.Text28.Text = Text4.Text
frmHistory.Text29.Text = Text5.Text
frmHistory.Text30.Text = Text6.Text
frmHistory.Text31.Text = Text7.Text
frmHistory.Text32.Text = Text8.Text
frmHistory.Text33.Text = Text9.Text
frmHistory.Text34.Text = Text10.Text
frmHistory.Data3.Recordset.Update
frmHistory.Data3.Recordset.MoveNext
If frmHistory.Data3.Recordset.EOF Then Exit Do
Loop
Adodc2.Recordset.MoveNext
If Adodc2.Recordset.EOF = True Then
Command1.Enabled = False
End If
End Sub

Jun 15th, 2000, 04:21 AM
' Need to check there are actual records, and
' position first...if ya want to update all records
'
if Not frmHistory.data3.Recordset.BOF and Not frmhistory.data3.Recordset.Eof Then
frmHistory.data3.Recordset.MoveFirst
Do
frmHistory.data3.Recordset.Edit
frmHistory.data3.Recordset!Text2 = "" & Text3
frmHistory.data3.Recordset.Update
frmHistory.data3.Recordset.MoveNext
If frmHistory.EOF Then Exit Do
Loop
End If

yinyin
Jun 15th, 2000, 07:36 AM
Originally posted by Jethro
' Need to check there are actual records, and
' position first...if ya want to update all records
'
if Not frmHistory.data3.Recordset.BOF and Not frmhistory.data3.Recordset.Eof Then
frmHistory.data3.Recordset.MoveFirst
Do
frmHistory.data3.Recordset.Edit
frmHistory.data3.Recordset!Text2 = "" & Text3
frmHistory.data3.Recordset.Update
frmHistory.data3.Recordset.MoveNext
If frmHistory.EOF Then Exit Do
Loop
End If


well it doesnt seem to work. it doesnt even update the second record. it stay with the first record I enter.if i enter a new record it doesnt appear.

I have something in mind. Do you think is possible to refresh the form after I exit from it. Meaning let say I search for the record and update it to the db then view in the report.After i close the report i wanna refresh the form.so what do u think. Hopeto hear from u soon. Thank in advance.u really help me a lot.U r a nice guy :)