Results 1 to 10 of 10

Thread: RE:Help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    14

    Exclamation

    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

  2. #2
    Guest

    Question Please explain

    What are you trying to update?????? What goes in text3???????, you need a Edit and Update for each record ya want updated

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    14

    Re: Please explain

    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.

  4. #4
    Guest

    Try something like

    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.

  5. #5
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    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.

    Code:
    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...

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    14
    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.

    Code:
    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

  7. #7
    Guest

    Unhappy Oops!!!!!!!!!!!!!!!

    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.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    14

    Re: Oops!!!!!!!!!!!!!!!

    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

  9. #9
    Guest

    Smile Ok got the problem

    ' 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

  10. #10

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    14

    Re: Ok got the problem

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width