Results 1 to 21 of 21

Thread: [RESOLVED] Abt move records

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    35

    Resolved [RESOLVED] Abt move records

    Hello All

    I got stuck at one place


    here goes decription

    I HAVE one combo from which
    on click we can see records on text boxes
    and in also have move next,last prev butoons

    i used requery.for this

    problem is when i click on combo it shows me records 1,2,3,4,....
    bt after that if i click after this on move next,prev

    it shud show next or prev of selected records frm combo right?
    bt if click on next or prev
    it startes frm first record

    can u tell pls how to connect this combo and move next,prev buttons together?

    thanks in advance
    Ash

  2. #2
    Member the maj's Avatar
    Join Date
    Jun 2006
    Location
    Shanghai, China
    Posts
    47

    Re: Abt move records

    ash007,

    You're entry is a little confusing. Why don't you explain clearly what you want to accomplish as opposed to what you have. I'm sure we can help you better.

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    35

    Re: Abt move records

    i have a combo box 'selectcombo'

    when i click on it according to selected membernumb i can see getrecords in the respective text box

    as im directly fetching records frm recordset

    after this if user clicks on movenext or moveprevios

    that button shud wrk moveprev or movenext records as per that selected member in combo

    and vice versaaaa

    so how to related tht combo and movenext and prev.buttons!

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    35

    Re: Abt move records

    Private Sub cmbGuestNo_Click()
    If cmbGuestNo = "" Then Exit Sub
    rsGain.Filter = "MembershipNo= '" & Trim(cmbGuestNo.Text) & "'"
    If rsGain.EOF = False Or rsGain.BOF = False Then
    'rsGain.MoveLast

    GETFIELDS ''''''''''''''fetching records
    End If
    rsGain.Filter = ""

    End Sub


    i cant put general click fetching records like this also ..not using flexi!
    ' SQL = "Select * from MemberRegistrationDetails where MembershipNo='" & Trim(cmbGuestNo.Text) & "'"
    ' Set rsGain = GetRecordset(SQL)
    ' GETFIELDS
    ' GetFamilyRecord
    ' If rsFamilyMember.RecordCount <> 0 Then
    ' GETFAMILYFIELDS
    ' End If


    ---------------------------------------------
    on

    Sub On_next()
    'clicked on next button of toolbar

    If Not (rsGain.EOF Or rsGain.BOF) Then
    rsGain.MoveNext
    End If
    GETFIELDS

    end sub

  5. #5
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Abt move records

    I think the problem is on Sub On_next().
    Becuase when you call that, if the rs is at EOF or BOF, it wont move, but instead it would call GETFIELDS.
    EG:
    you have 5 records. so when you reach 5 th record, after that if you call it wont go to the Next since its the End. But it will load the current record , the 5 th record, again.
    Hope I made it clear. So you could change that to something like this

    Code:
    Sub On_next()  'clicked on next button of toolbar
    
    If Not (rsGain.EOF Or rsGain.BOF) Then
         rsGain.MoveNext
         GETFIELDS
    Else
        msgbox "End Of Records!"
        ' may cleare the text boxes or move to the first and load that.
    End If
    
    
    end sub
    Again if you have similar functions like that, put GETFIELDS inside the End IF.
    IIF(Post.Rate > 0 , , )

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    35

    Re: Abt move records

    yes this code is wrking

    ya im telling that problem only

    as when i click on next

    or prev button

    records shud move next or previous according to the selected gurstnumb frm combobox


    for eg. c1,c2,c,3,c4,c5,c6,c7 records


    im selecting frm combo c1,c2
    if user changes his/her mind and clicked on movenext
    then on movenext click i do expect to see records of c3,c4...
    if clicked on previous i expect to move on record of c1!

    bt currently if i click on move nxt/prev i can see records frm again c1,c2 //..

    so it will b difficult to handle if records will b 1000,2000
    i hope it is much more cleared
    pls tell me on this

  7. #7
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Abt move records

    TO be Frank. Its not clear enough .

    Ok tell me the process is like this.

    1. Load some guest names to Combo.
    2. When you select a name/MemberNo from combo, load that to text boxes. and filter the recordset to that memberno/Name
    3. When you click on move next ,previous, move the recordset on current filter

    OR
    do you want to move the recordset on all the records?



    BTW , I think you should use like rsGain.Filter = adFilterNone, not like rsGain.Filter = "' (I m not sure though)
    IIF(Post.Rate > 0 , , )

  8. #8

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    35

    Re: Abt move records

    on form load

    the combobox is visible

    it is an option for flex as i dont /cant put flexgrid at this stage

    from combo u can select membercode

    select c1 u will see records like firstname,lastname...of that member in the text boxess

    select c2 same..c3,c4....

    till this program is ok..
    suppose i reached till c4 from combobox n i can see values

    after this if i select movenext buttons then

    then i must see records of c5bt i can see record first that is c1

    any refresh meethod for recordset?

  9. #9
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Abt move records

    Only refresh command I can think of is requery. And since you are using Filter rsGain.Filter = adFilterNone also.
    Can you post the code for Combo click and move Next Move Previuos ?
    IIF(Post.Rate > 0 , , )

  10. #10

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    35

    Re: Abt move records

    Hello Sir
    as per u said giving code here
    i hope nw i will get ans
    ===================================
    Private Sub cmbGuestNo_Click()
    If cmbGuestNo = "" Then Exit Sub
    rsGain.Filter = "MembershipNo= '" & Trim(cmbGuestNo.Text) & "'"
    If rsGain.EOF = False Or rsGain.BOF = False Then
    'rsGain.MoveLast

    GETFIELDS
    End If
    rsGain.Filter = ""
    End Sub
    =========================
    Sub On_next()
    If Not (rsGain.EOF Or rsGain.BOF) Then
    rsGain.MoveNext
    End If
    GETFIELDS
    GetFamilyRecord
    If rsFamilyMember.RecordCount <> 0 Then
    GETFAMILYFIELDS
    Else
    flxFamilyDetails.Clear
    End If
    End Sub
    ============================
    Sub On_prev() 'clicked on previous button of toolbar

    If rsGain.BOF = True Then
    rsGain.MoveLast
    ElseIf rsGain.BOF = False Then
    rsGain.MovePrevious
    End If
    If rsGain.BOF = False Then
    GETFIELDS
    GetFamilyRecord
    If rsFamilyMember.RecordCount <> 0 Then
    GETFAMILYFIELDS
    Else
    flxFamilyDetails.Clear
    End If
    Else
    'rsRegistration.MoveLast
    End If

    End Sub

  11. #11
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Abt move records

    This is MSDN about EOF and BOF


    BOF, EOF Properties


    BOF — Indicates that the current record position is before the first record in a Recordset object.


    EOF — Indicates that the current record position is after the last record in a Recordset object.
    Return Value

    The BOF and EOF properties return Boolean values.

    Remarks

    Use the BOF and EOF properties to determine whether a Recordset object contains records or whether you've gone beyond the limits of a Recordset object when you move from record to record.

    The BOF property returns True (-1) if the current record position is before the first record and False (0) if the current record position is on or after the first record.

    The EOF property returns True if the current record position is after the last record and False if the current record position is on or before the last record.

    If either the BOF or EOF property is True, there is no current record.

    If you open a Recordset object containing no records, the BOF and EOF properties are set to True, and the Recordset object's RecordCount property setting is zero. When you open a Recordset object that contains at least one record, the first record is the current record and the BOF and EOF properties are False.

    If you delete the last remaining record in the Recordset object, the BOF and EOF properties may remain False until you attempt to reposition the current record.

    This table shows which Move methods are allowed with different combinations of the BOF and EOF properties.




    Allowing a Move method doesn't guarantee that the method will successfully locate a record; it only means that calling the specified Move method won't generate an error.

    The following table shows what happens to the BOF and EOF property settings when you call various Move methods but are unable to successfully locate a record.



    So according to this your next and previous should chenge
    IIF(Post.Rate > 0 , , )

  12. #12
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Abt move records

    So according to that I changed the code
    Code:
    Option Explicit
    
    Private Sub cmbGuestNo_Click()
        If cmbGuestNo = "" Then Exit Sub
        
        rsGain.Filter = "MembershipNo= '" & Trim(cmbGuestNo.Text) & "'"
        If rsGain.EOF = False Or rsGain.BOF = False Then
            'rsGain.MoveLast
        
            GETFIELDS
            'may add the other loading functions also ????
    '        GetFamilyRecord
    '        If rsFamilyMember.RecordCount <> 0 Then
    '            GETFAMILYFIELDS
    '        Else
    '            flxFamilyDetails.Clear
    '        End If
    
        End If
        rsGain.Filter = adFilterNone
    End Sub
    Sub On_next()
        If Not rsGain.EOF Then
            rsGain.MoveNext
            GETFIELDS
            GetFamilyRecord
            If rsFamilyMember.RecordCount <> 0 Then
                GETFAMILYFIELDS
            Else
                flxFamilyDetails.Clear
            End If
        Else
            MsgBox "End Of Records"
        End If
        
    End Sub
    Sub On_prev() 'clicked on previous button of toolbar
        
        If rsGain.BOF = True Then
            rsGain.MoveLast
        ElseIf rsGain.BOF = False Then
            rsGain.MovePrevious
        End If
        
        If rsGain.BOF = False Then
            GETFIELDS
            GetFamilyRecord
            If rsFamilyMember.RecordCount <> 0 Then
            GETFAMILYFIELDS
            Else
            flxFamilyDetails.Clear
            End If
        Else
            'rsRegistration.MoveLast
        End If
    
    End Sub
    Hope this would fix your problem.
    Could you explain what you ment by this in POST#1 ?

    it shud show next or prev of selected records frm combo right?
    And please enclose your code in code tags when you post. Its easier to read with that. There is button on the Posting screen called CODE. use that or the highlight = vb tags.

    Last edited by zeezee; Oct 27th, 2007 at 08:22 AM.
    IIF(Post.Rate > 0 , , )

  13. #13

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    35

    Re: Abt move records

    hello sir

    ok..

    when i click on combo it shows me records 1,2,3,4,....for eg.im on 4th record
    bt after that if i click after this on move next,prev
    when clicked on nextit shud show 5th record
    or when clicked on previshud show 3 record

    we r keeping 4th record as selected frm combo

    bt currently if click on next or prev
    it starts frm first record i.e.1st record

    can u plz tell me ..how to relate that selected record frm combo and next,prev commands
    ash

  14. #14
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Abt move records

    Sorry , but not getting you correctly.
    Did you try the code I gave in previous post?

    And ther might me other bugs , like filtering in other functions or querrying again.
    IIF(Post.Rate > 0 , , )

  15. #15

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    35

    Re: Abt move records

    yes tried that one
    bt i got stucked @that point
    [< ][>]
    its just case question of a combo box and movenext/previous buttons matter

    i dont knw how to related both things as on indivisual level both are working perfectly

    if u click combo u will get all records acc to customer numb

    bt move ments of records is not working

    bt if u close that form and do movements as move next/previous then it wrks properly

    can u pls tell me wht is confusing in my statements?
    ash

  16. #16
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Abt move records

    Actually I m not getting it at all.
    sorry.
    OK try this.
    remove the line rsGain.Filter = adFilterNone in the combo click. then try moving.

    What is confusing i how you want the moving part to work. Do you want to traverse the current loaded/selected records or the entire record set?
    IIF(Post.Rate > 0 , , )

  17. #17

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    35

    Re: Abt move records

    Hello sir
    how r u?

    i didnt get any intimation mail on my mail id of ur last reply

    so while check forums i saw ur reply .
    actully i ignored that problem bt it will persist in future..

    see.. the things are

    imagine a form having all fields like name add. ph numb. i dont have flexgrid
    so after saving record..for eg i saved 23d record and i want to check 12th record
    for tht purpose ikept combobox if i know member id then i click on combo and select that i d i will get records of that id.
    if i want to see 24th record then i will use movenext button.

    am i right?????
    till this its simple i hope u get my point
    and assuming u got it i will proceed ...
    1.when i select 12th record from combo and i want to see 13th record..
    if i used movenext. movenext buttton doesnt work.it is still on 1st record not on 12th!

    2.similiarly if i used move next button till 10th record then used combo for 11th record combo shows me first 1st ,2d .....records go on!

    so let me know ..
    thanks
    ash

  18. #18
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Abt move records

    Welcome Back

    try this

    Code:
    Private Sub cmbGuestNo_Click()
        Dim absPos As Long
        If cmbGuestNo = "" Then Exit Sub
        
        rsGain.Filter = "MembershipNo= '" & Trim(cmbGuestNo.Text) & "'"
        absPos = rsGain.AbsolutePosition
        If rsGain.EOF = False Or rsGain.BOF = False Then
            'rsGain.MoveLast
        
            GETFIELDS
        End If
        rsGain.Filter = adFilterNone
        If absPos > 0 Then rsGain.Move absPos
    
    End Sub
    couldnt realy try this, but it should work i think

    Last edited by zeezee; Dec 20th, 2007 at 03:02 AM.
    IIF(Post.Rate > 0 , , )

  19. #19

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    35

    Re: Abt move records

    Hello sir

    it works for combo.
    bt not for movement of records

    here im attching a dummy screenshot for ur ref.
    u told me code for combo click
    so proceeding with that if i click combo n get record no3
    and then if user click on movenext or previous logically it shud give us record no 2 or 4 so absol. position shud wrk in movenext..move previous..
    i tried it bt it gives error..
    i dont find msdn info sufficient cos i tried that..

    i think it is one of major prob
    Attached Files Attached Files

  20. #20
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Abt move records

    Well, I cant get any info form that screen shot .
    When do you load the values to the combo? A seperate recordset or by traversing the same recordset?
    If its second method, then what you could do is keep the position t in an dimensional array. its index should match to the listindex of the combo box. So when you use the combo click , rather than using a filter, move to the record using the position by using combo.ListIndex

    Or instead of a combo box, use a list box. List box has ItemData(Index) array built in. so you can store the posistion in that array. then move to the record using rst.Move

    or use the Recordset Find method. I havent used this but if you have MSDN , then there is help

    I think there is no other way to do this.


    IIF(Post.Rate > 0 , , )

  21. #21

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    35

    Re: Abt move records

    problem solved!


    thanks sir for ur time

    i used bookmark

    thanks all replies

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