-
Hi, I am trying to get a loop to show the Client's name on the form I am loading but it skips the Clients name and leaves things blank. The user click on a user in a listview and then it goes to this form. Now the code I have for the form is:
Set qryDef = pDatabase.QueryDefs("QryResults")
Set mRstrans = qryDef.OpenRecordset(, dbOpenDynaset)
dd = Mid$(FrmMain.LsvDetails.SelectedItem.Key, 2)
'dd is the current selected user
Do Until mRstrans.EOF
If dd = mRstrans!RAccountID Then
LabM.Caption = mRstrans!Measurement
LabDate.Caption = mRstrans!RDate
LabWeight.Caption = mRstrans!WeightScale
LabName.Caption = mRstrans!GivenName & " " & mRstrans!Surname
mRstrans.MoveLast
Else
mRstrans.MoveNext
End If
Loop
mRstrans.Close
Now as I was saying it goes through the list but when I create a new client and go to this form it doesn't load it in the labels provided so the user can't see who he/she is editing. When it gets to the correct id in "dd" it just skips from the line "Do until mRstrans.EOF" down to "mRstrans.close". It is a strange problem. I have use movenext in the line that says "mRstrans.MoveLast" but it just stuffs up.
Any ideas would be much appreciated and thanks in advance.
Mike
[This message has been edited by Spawny (edited 08-03-1999).]
-
I guess you are not closing the Recordset completely.
You should also use mRstrans=Nothing
Also Instead of loop you can try this
mRstrans.findfirst "RAccountId=" & dd
if mrstrans.nomatch then
msgbox "Not Found"
else
LabM.Caption = mRstrans!Measurement
LabDate.Caption = mRstrans!RDate
LabWeight.Caption = mRstrans!WeightScale
LabName.Caption = mRstrans!GivenName & " " & mRstrans!Surname
end if
mRstrans.close
Set mRstrans=Nothing
I hope this helps
-
Thanks for trying to help me Kishore and I did try your idea and code but end up with the same problem. I have figured it out now. It is because i haven't got a first record for it to load for that particular client. I am trying to fix that but I have a few dramas with that as well. See new question.
Thanks once again.
Mike
[This message has been edited by Spawny (edited 08-04-1999).]
-
Set a break point after 'else' Statement at
LabM.Caption = mRstrans!Measurement
Run the Application
Create a new client and click on list view or whatever.
See if the application stops at that point.
If it doesn't then there is no data.
if it does then probably the records are blank. I think you when you created a new client you may be able to enter the client name but not rest of fields. You may open the database and see it for yourself. If there are Records, then i think that may be something to do with refreshing the Recordset.
Looking forward for results.
[This message has been edited by kishore (edited 08-04-1999).]