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.
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
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.
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
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)
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 ?
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
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
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.
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
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!
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.
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..
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