473,473 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Evil Clones!

JustJim
407 Recognized Expert Contributor
I thought that this was a fairly standard method of finding a record in a form.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboGender_Exit(Cancel As Integer)
  2.     ' Find the record that matches the form header.
  3. Dim dbNA As Database
  4. Dim strSearch As String
  5. Dim rsSchoolName As Recordset
  6. Dim rsData As Object
  7. Dim strSQL As String
  8.  
  9. strSearch = "(Surname = '" & Me.cboSurname & "') AND " _
  10.         & "([First_Names]= '" & Me.cboFirstNames & "') AND " _
  11.         & "(DOB = #" & Format(Me.cboDoB, "MM/DD/YYYY") & "#) AND " _
  12.         & "(Gender = '" & Me.cboGender & "')"
  13.  
  14.     Set rsData = Me.Recordset.Clone
  15.     rsData.FindFirst strSearch
  16.     If Not rsData.EOF Then Me.Bookmark = rsData.Bookmark
  17.  
  18. ' Some other stuff
  19. End Sub
The search string is made up of the contents of four cascading combo boxes in the form's header and the form does in fact show the correct student's details.

However.... another student's record is changed so that the other student gets given the Surname of the student that I search for!

I suspect that this is because I'm working with two recordsets, but I don't understand it at all. Do I need to apply an index to the cloned recordset?

I also can't see the relationship between the record searched for and the one that gets changed. If I close the form and re-open it and search for the same student, another, different record gets changed.

No wonder the wierdo right-wingers are against cloning! :)

Jim (the mad scientist's Igor)
Nov 20 '07 #1
4 1236
ADezii
8,834 Recognized Expert Expert
I thought that this was a fairly standard method of finding a record in a form.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboGender_Exit(Cancel As Integer)
  2.     ' Find the record that matches the form header.
  3. Dim dbNA As Database
  4. Dim strSearch As String
  5. Dim rsSchoolName As Recordset
  6. Dim rsData As Object
  7. Dim strSQL As String
  8.  
  9. strSearch = "(Surname = '" & Me.cboSurname & "') AND " _
  10.         & "([First_Names]= '" & Me.cboFirstNames & "') AND " _
  11.         & "(DOB = #" & Format(Me.cboDoB, "MM/DD/YYYY") & "#) AND " _
  12.         & "(Gender = '" & Me.cboGender & "')"
  13.  
  14.     Set rsData = Me.Recordset.Clone
  15.     rsData.FindFirst strSearch
  16.     If Not rsData.EOF Then Me.Bookmark = rsData.Bookmark
  17.  
  18. ' Some other stuff
  19. End Sub
The search string is made up of the contents of four cascading combo boxes in the form's header and the form does in fact show the correct student's details.

However.... another student's record is changed so that the other student gets given the Surname of the student that I search for!

I suspect that this is because I'm working with two recordsets, but I don't understand it at all. Do I need to apply an index to the cloned recordset?

I also can't see the relationship between the record searched for and the one that gets changed. If I close the form and re-open it and search for the same student, another, different record gets changed.

No wonder the wierdo right-wingers are against cloning! :)

Jim (the mad scientist's Igor)
Try changing Lines 6 and 14, if not let's see the 'other stuff':
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboGender_Exit(Cancel As Integer)
  2.     ' Find the record that matches the form header.
  3. Dim dbNA As Database
  4. Dim strSearch As String
  5. Dim rsSchoolName As Recordset
  6. Dim rsData As DAO.Recordset
  7. Dim strSQL As String
  8.  
  9. strSearch = "(Surname = '" & Me.cboSurname & "') AND " _
  10.         & "([First_Names]= '" & Me.cboFirstNames & "') AND " _
  11.         & "(DOB = #" & Format(Me.cboDoB, "MM/DD/YYYY") & "#) AND " _
  12.         & "(Gender = '" & Me.cboGender & "')"
  13.  
  14. Set rsData = Me.RecordsetClone
  15. rsData.FindFirst strSearch
  16. If Not rsData.EOF Then Me.Bookmark = rsData.Bookmark
  17.  
  18. ' Some other stuff
  19. End Sub
Nov 21 '07 #2
JustJim
407 Recognized Expert Contributor
Try changing Lines 6 and 14, if not let's see the 'other stuff':
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboGender_Exit(Cancel As Integer)
  2.     ' Find the record that matches the form header.
  3. Dim dbNA As Database
  4. Dim strSearch As String
  5. Dim rsSchoolName As Recordset
  6. Dim rsData As DAO.Recordset
  7. Dim strSQL As String
  8.  
  9. strSearch = "(Surname = '" & Me.cboSurname & "') AND " _
  10.         & "([First_Names]= '" & Me.cboFirstNames & "') AND " _
  11.         & "(DOB = #" & Format(Me.cboDoB, "MM/DD/YYYY") & "#) AND " _
  12.         & "(Gender = '" & Me.cboGender & "')"
  13.  
  14. Set rsData = Me.RecordsetClone
  15. rsData.FindFirst strSearch
  16. If Not rsData.EOF Then Me.Bookmark = rsData.Bookmark
  17.  
  18. ' Some other stuff
  19. End Sub
I'll try than now. I don't think it can be the "other stuff". The problem occurs with the other stuff Rem'd out and a breakpoint before it.

I'll be back.

Jim
Nov 21 '07 #3
JustJim
407 Recognized Expert Contributor
OK changed the on-exit event of the last combo box to:-
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboGender_Exit(Cancel As Integer)
  2.     ' Find the record that matches the form header.
  3. Dim dbNA As Database
  4. Dim strSearch As String
  5. Dim rsSchoolName As Recordset
  6. Dim rsData As DAO.Recordset
  7. Dim strSQL As String
  8.  
  9. strSearch = "(Surname = '" & Me.cboSurname & "') AND " _
  10.         & "([First_Names] = '" & Me.cboFirstNames & "') AND " _
  11.         & "(DOB = #" & Format(Me.cboDoB, "MM/DD/YYYY") & "#) AND " _
  12.         & "(Gender = '" & Me.cboGender & "')"
  13.  
  14.     Set rsData = Me.RecordsetClone
  15.     rsData.FindFirst strSearch
  16.     If Not rsData.EOF Then Me.Bookmark = rsData.Bookmark
  17.  
  18. 'strSQL = "SELECT ALL_SCHOOLS.SCHOOL_NAME " _
  19. '        & "FROM ALL_SCHOOLS INNER JOIN ALL_CAMPUSES ON ALL_SCHOOLS.SCHOOL_NO = ALL_CAMPUSES.SCHOOL_NO " _
  20. '        & "WHERE (((ALL_CAMPUSES.SCHOOL_NO)= " & Me.txtSchoolNo & ") AND ((ALL_CAMPUSES.CAMPUS_NO) = " & Me.txtCampusNo & "))"
  21. 'Set dbNA = CurrentDb()
  22. 'Set rsSchoolName = dbNA.OpenRecordset(strSQL, dbOpenDynaset)
  23. 'Me!txtEnrolmentSchool.Value = rsSchoolName!SCHOOL_NAME
  24.  
  25. 'strSQL = "SELECT ALL_SCHOOLS.SCHOOL_NAME " _
  26. '        & "FROM Tbl_Outpost_Hosts INNER JOIN (ALL_SCHOOLS INNER JOIN ALL_CAMPUSES ON ALL_SCHOOLS.SCHOOL_NO = ALL_CAMPUSES.SCHOOL_NO) ON Tbl_Outpost_Hosts.Host_School_Number = ALL_SCHOOLS.SCHOOL_NO " _
  27. '        & "WHERE ((Tbl_Outpost_Hosts.Host_School_Number)= " & Me.cboOutpost_Host_ID.Column(1) & ")"
  28. 'Set dbNA = CurrentDb()
  29. 'Set rsSchoolName = dbNA.OpenRecordset(strSQL, dbOpenDynaset)
  30. 'If rsSchoolName.EOF Then
  31. '    Me!txtOutpostHost.Value = "Not Set"
  32. 'Else
  33. '    Me!txtOutpostHost.Value = rsSchoolName!SCHOOL_NAME
  34. 'End If
  35.  
  36. 'Me.cboProg_Type_ID.SetFocus
  37. End Sub
(this includes the 'other stuff')
I thought I was doing OK because when it stoped at a breakpoint before the rem'd out stuff I got:
? rsdata!surname, rsdata!first_Names, me.RecordsetClone!surname, me.RecordsetClone!first_names
nang Htay Htay hlaing nang Htay Htay hlaing
in the immediate window (don't laugh, it's her name - yes really)
but when I let it finish and look at tblStudents, I find two with the surname "Nang" where there was only one before!
I can post the cascading combo boxes if you think that may be the problem.

Jim
Nov 21 '07 #4
JustJim
407 Recognized Expert Contributor
Just noticed that the parser didn't capitalise the dao in dao.RecordSet. I do have

Microsoft 3.6 DAO Object Library

selected as a reference though.

Jim
Nov 21 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: O'Neal Computer Programmer | last post by:
*** First of all, if there is a previous post on Temple of Elemental Evil, please provide a link to that/them so in order to create a larger resource on this game. Thanks! (Merci) ;-) *** Temple...
2
by: Russell Reagan | last post by:
In a newer version of a chess program I am writing, I have created classes that are (more or less) drop in replacements for things that used to be plain old integer or enumerated variables (colors,...
14
by: rogerclive | last post by:
Perhaps, there is no bigger sleazy company in the entire Maple Republic ( Canada ) than Matrox Graphics Inc. I paid $100+ through my nose circa 1999 for Matrox Millenium II and Mystique. It...
7
by: Reply Via Newsgroup | last post by:
This might sound sad... someone requesting a disertation on the 'eval' statement... but... I've been reading someone else's post - they had a huge calander like script and a handful of folk cursed...
6
by: Brian Raab | last post by:
I must warn you, evil script-kiddies write evil programs to flood the usenet with stupid messages in C.They probably write worms and virus programs, too. So tell the daddies of the...
1
by: Swami Tota Ram Shankar | last post by:
"Bob Weigel" <dontuwish@nothing.net> wrote in message > > While George Bush, is the epitome of evil, racism, and uncompassionate > > conservatism, Kerry is either deluded, very deluded, or...
24
by: Larry | last post by:
Hi there: I have seen numerous postings about eval() and its evils on this forum. However, one of our developers is using it in the following way, which seems like a great use of it. Page...
0
by: baseballswim123 | last post by:
Friend, I'm always looking for good and intelligent individuals like you to visit my website, www.ChezBrandon.com, and it has pictures of beautiful women, information about aged clones, and a...
6
by: Chad Crabtree | last post by:
As I'm sure some of you already know there is quite a bit of stir on Reddit about a few Javascript Rails clones. Both of them run on Rhino, which brings me to my question. Why is it that both...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.