JustJim 407
Recognized Expert Contributor
I thought that this was a fairly standard method of finding a record in a form. - Private Sub cboGender_Exit(Cancel As Integer)
-
' Find the record that matches the form header.
-
Dim dbNA As Database
-
Dim strSearch As String
-
Dim rsSchoolName As Recordset
-
Dim rsData As Object
-
Dim strSQL As String
-
-
strSearch = "(Surname = '" & Me.cboSurname & "') AND " _
-
& "([First_Names]= '" & Me.cboFirstNames & "') AND " _
-
& "(DOB = #" & Format(Me.cboDoB, "MM/DD/YYYY") & "#) AND " _
-
& "(Gender = '" & Me.cboGender & "')"
-
-
Set rsData = Me.Recordset.Clone
-
rsData.FindFirst strSearch
-
If Not rsData.EOF Then Me.Bookmark = rsData.Bookmark
-
-
' Some other stuff
-
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)
4 1236 ADezii 8,834
Recognized Expert Expert
I thought that this was a fairly standard method of finding a record in a form. - Private Sub cboGender_Exit(Cancel As Integer)
-
' Find the record that matches the form header.
-
Dim dbNA As Database
-
Dim strSearch As String
-
Dim rsSchoolName As Recordset
-
Dim rsData As Object
-
Dim strSQL As String
-
-
strSearch = "(Surname = '" & Me.cboSurname & "') AND " _
-
& "([First_Names]= '" & Me.cboFirstNames & "') AND " _
-
& "(DOB = #" & Format(Me.cboDoB, "MM/DD/YYYY") & "#) AND " _
-
& "(Gender = '" & Me.cboGender & "')"
-
-
Set rsData = Me.Recordset.Clone
-
rsData.FindFirst strSearch
-
If Not rsData.EOF Then Me.Bookmark = rsData.Bookmark
-
-
' Some other stuff
-
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': -
Private Sub cboGender_Exit(Cancel As Integer)
-
' Find the record that matches the form header.
-
Dim dbNA As Database
-
Dim strSearch As String
-
Dim rsSchoolName As Recordset
-
Dim rsData As DAO.Recordset
-
Dim strSQL As String
-
-
strSearch = "(Surname = '" & Me.cboSurname & "') AND " _
-
& "([First_Names]= '" & Me.cboFirstNames & "') AND " _
-
& "(DOB = #" & Format(Me.cboDoB, "MM/DD/YYYY") & "#) AND " _
-
& "(Gender = '" & Me.cboGender & "')"
-
-
Set rsData = Me.RecordsetClone
-
rsData.FindFirst strSearch
-
If Not rsData.EOF Then Me.Bookmark = rsData.Bookmark
-
-
' Some other stuff
-
End Sub
JustJim 407
Recognized Expert Contributor Try changing Lines 6 and 14, if not let's see the 'other stuff': -
Private Sub cboGender_Exit(Cancel As Integer)
-
' Find the record that matches the form header.
-
Dim dbNA As Database
-
Dim strSearch As String
-
Dim rsSchoolName As Recordset
-
Dim rsData As DAO.Recordset
-
Dim strSQL As String
-
-
strSearch = "(Surname = '" & Me.cboSurname & "') AND " _
-
& "([First_Names]= '" & Me.cboFirstNames & "') AND " _
-
& "(DOB = #" & Format(Me.cboDoB, "MM/DD/YYYY") & "#) AND " _
-
& "(Gender = '" & Me.cboGender & "')"
-
-
Set rsData = Me.RecordsetClone
-
rsData.FindFirst strSearch
-
If Not rsData.EOF Then Me.Bookmark = rsData.Bookmark
-
-
' Some other stuff
-
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
JustJim 407
Recognized Expert Contributor
OK changed the on-exit event of the last combo box to:- - Private Sub cboGender_Exit(Cancel As Integer)
-
' Find the record that matches the form header.
-
Dim dbNA As Database
-
Dim strSearch As String
-
Dim rsSchoolName As Recordset
-
Dim rsData As DAO.Recordset
-
Dim strSQL As String
-
-
strSearch = "(Surname = '" & Me.cboSurname & "') AND " _
-
& "([First_Names] = '" & Me.cboFirstNames & "') AND " _
-
& "(DOB = #" & Format(Me.cboDoB, "MM/DD/YYYY") & "#) AND " _
-
& "(Gender = '" & Me.cboGender & "')"
-
-
Set rsData = Me.RecordsetClone
-
rsData.FindFirst strSearch
-
If Not rsData.EOF Then Me.Bookmark = rsData.Bookmark
-
-
'strSQL = "SELECT ALL_SCHOOLS.SCHOOL_NAME " _
-
' & "FROM ALL_SCHOOLS INNER JOIN ALL_CAMPUSES ON ALL_SCHOOLS.SCHOOL_NO = ALL_CAMPUSES.SCHOOL_NO " _
-
' & "WHERE (((ALL_CAMPUSES.SCHOOL_NO)= " & Me.txtSchoolNo & ") AND ((ALL_CAMPUSES.CAMPUS_NO) = " & Me.txtCampusNo & "))"
-
'Set dbNA = CurrentDb()
-
'Set rsSchoolName = dbNA.OpenRecordset(strSQL, dbOpenDynaset)
-
'Me!txtEnrolmentSchool.Value = rsSchoolName!SCHOOL_NAME
-
-
'strSQL = "SELECT ALL_SCHOOLS.SCHOOL_NAME " _
-
' & "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 " _
-
' & "WHERE ((Tbl_Outpost_Hosts.Host_School_Number)= " & Me.cboOutpost_Host_ID.Column(1) & ")"
-
'Set dbNA = CurrentDb()
-
'Set rsSchoolName = dbNA.OpenRecordset(strSQL, dbOpenDynaset)
-
'If rsSchoolName.EOF Then
-
' Me!txtOutpostHost.Value = "Not Set"
-
'Else
-
' Me!txtOutpostHost.Value = rsSchoolName!SCHOOL_NAME
-
'End If
-
-
'Me.cboProg_Type_ID.SetFocus
-
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
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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,...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |