Rabu, 08 Agustus 2012

Re: [MS_AccessPros] A Query Problem (Redux)

 

Okay, that didn't work so clearly you cannot attach a file, but I'm not sure what the process is.  I've only read postings or asked questions.  I've never uploaded a file.

Dan

________________________________
From: Dan Fielding <amessyguy@yahoo.com>
To: "MS_Access_Professionals@yahoogroups.com" <MS_Access_Professionals@yahoogroups.com>
Sent: Wednesday, August 8, 2012 9:00 PM
Subject: Re: [MS_AccessPros] A Query Problem (Redux)

Here is a smaller version of the whole thing.

Two teachers - Sullivan, Jimenez
One grade level - 4

Dan

________________________________
From: Bill Mosca <wrmosca@comcast.net>
To: MS_Access_Professionals@yahoogroups.com
Sent: Tuesday, August 7, 2012 2:00 PM
Subject: Re: [MS_AccessPros] A Query Problem (Redux)

Dan

Yes, you explained it correctly. I can't see why the process is not working. Would it be possible to upload a small, zipped sample database? It would only need the form, module and table(s) used.

Bill

--- In MS_Access_Professionals@yahoogroups.com, Dan Fielding <amessyguy@...> wrote:
>
> Sorry, pressed send by accident!!!
>
> As I was saying, a little of both, I think.  Since this part:
>
> Private Sub cmdContinueACC_Click()
>
>    Dim strTName As String
>    
>     If Me.txtTeacherName <> "" Then
>         SetName Me.txtTeacherName
>         DoCmd.OpenForm "frmACCForm", acNormal
>         DoCmd.Close acForm, "frmSelectByTeacherACC", acSaveNo
>     Else
>         MsgBox "Please enter a name.", vbOKOnly, "Teacher Name required"
>     End If
> End Sub
>
> is associated with a command button on a Form does that make it a Form module?
>
> This part:
>
> Private strName As String
>
> Public Sub SetName(Value As String)
>    strName = Value
> End Sub
>
> Public Function TName()
>    TName = strName
> End Function
>
>
> is part of a bas module, so I assume that's a standard module?
>
> The top section of code is located in the Microsoft Office Access Class Objects "folder" and the second part is in themodules "folder" in the VBA code window.
>
>
>
>
> ________________________________
>  From: Bill Mosca <wrmosca@...>
> To: MS_Access_Professionals@yahoogroups.com
> Sent: Monday, August 6, 2012 1:58 PM
> Subject: Re: [MS_AccessPros] A Query Problem (Redux)

> Dan
>
> Your functions and variables are in a standard module and not a form module, right?
>
> Bill
>
> --- In MS_Access_Professionals@yahoogroups.com, Dan Fielding <amessyguy@> wrote:
> >
> > It is being passed, sort of, depending on if I ever selected a grade.
> >
> > If I've never selected a grade, only teachers, and check the contents of tname or strname I find the name being passed along as expected.  I then select by grade and it works.  However, if I switch back to selection by name and run through it I find that the the teacher's name is in the variable and the last grade selected is still in its respective variable.  When the program gets to this line:
> >
> > DoCmd.Close acForm, "frmSelectByTeacherACC", acSaveNo
> >
> >
> > it is at that point when the teacher's name disappears and the original grade level selected the last time is what is still being accessed.  It seems like the grade is winning out over the teacher name, which is disappearing--once grade is selected at least one time.  From then on the teacher name will show in the code--for a while, but not long enough to make it all the way through the code.
> >
> >
> >
> > Dan
> >
> >
> >
> > ________________________________
> >  From: Bill Mosca <wrmosca@>
> > To: MS_Access_Professionals@yahoogroups.com
> > Sent: Friday, August 3, 2012 4:52 PM
> > Subject: Re: [MS_AccessPros] A Query Problem (Redux)
> > 
> > Dan
> >
> > The code is jumping to the functions because they are called by the query which has to run before the form can open. It doesn't matter which one is called first.
> >
> > Is the strName being passed correctly?
> >
> > Bill
> >
> > --- In MS_Access_Professionals@yahoogroups.com, Dan Fielding <amessyguy@> wrote:
> > >
> > > When I follow what's happening after the break point I find the following:
> > >
> > > If I stay in the same category (name or. grade) it will always work.  As soon as I switch from one category to the other (from name to grade or grade to name) it will always display the selection prior to my switching no matter what else I select (grade or teacher).
> > >
> > > One thing I find a little confusing is if I enter a teacher name and follow the code as it executes, just after it runs the following line:
> > >
> > >        DoCmd.OpenForm "frmACCForm", acNormal
> > >
> > >
> > > It jumps to the Public Function for the grade and runs through it, as well:
> > >
> > > Public Function TGrade()
> > >    TGrade = intGrade
> > > End Function
> > >
> > >
> > > Then it jumps back to this line in the teacher name section:
> > >
> > > Public Function TName()
> > >
> > > and continues to the end.
> > >
> > > It does the reverse if I start with a grade level.
> > >
> > >
> > >
> > > ________________________________
> > >  From: Bill Mosca <wrmosca@>
> > > To: MS_Access_Professionals@yahoogroups.com
> > > Sent: Friday, August 3, 2012 2:04 PM
> > > Subject: Re: [MS_AccessPros] A Query Problem (Redux)
> > > 
> > > Dan
> > >
> > > I can't see anything wrong with that. Are you sure the name is being passed on? Make this change:
> > > If len(Me.txtTeacherName & vbNullString) <> 0 Then
> > >
> > > Put a break opint on that line and when the code breaks press F8 to step through the next line of code. If it skips {SetName Me.txtTeacherName} you'll know the text box is null or ""
> > >
> > > Bill
> > >
> > >
> > > --- In MS_Access_Professionals@yahoogroups.com, Dan Fielding <amessyguy@> wrote:
> > > >
> > > > Okay, what is it about Access that makes you crazy?!?!  You think you have a problem solved, then a few days later the problem is back.  The description of the problem is in the bottom section of this posting.  Here is the code I'm using to try to get values into a Query so a user can make a selection either by teacher or grade level.  (The code for the Grade Level is identical except for the names of the variables, etc.)
> > > >
> > > >
> > > > By Teacher:
> > > >
> > > >
> > > > Private Sub cmdContinueACC_Click()
> > > >
> > > >    Dim strTName As String
> > > >     If Me.txtTeacherName <> "" Then
> > > >         SetName Me.txtTeacherName
> > > >         DoCmd.OpenForm "frmACCForm", acNormal
> > > >         DoCmd.Close acForm, "frmSelectByTeacherACC", acSaveNo
> > > >     Else
> > > >         MsgBox "Please enter a name.", vbOKOnly, "Teacher Name required"
> > > >     End If
> > > > End Sub
> > > >
> > > >
> > > > Here is the Function that creates the value passed to the Query:
> > > >
> > > > Option Compare Database
> > > > Private strName As String
> > > >
> > > > ----------
> > > >
> > > > Public Sub SetName(Value As String)
> > > >    strName = Value
> > > > End Sub
> > > >
> > > > Public Function TName()
> > > >    TName = strName
> > > > End Function
> > > >
> > > > I used the QBE grid to create the Query, but here is the SQL code behind it:
> > > >
> > > > SELECT MasterList.ID, MasterList.LastName, MasterList.FirstName, MasterList.Teacher, MasterList.GradeLevel,
> > > > MasterList.MathExtendedTime, MasterList.MathCalculator, MasterList.MathVisualAid,
> > > > MasterList.ReadingReadAloud, MasterList.ReadingExtendedTime, MasterList.ReadingVisualAid,
> > > > MasterList.SSExtendedTime, MasterList.SSVisualAid,
> > > > MasterList.ScienceExtendedTime, MasterList.ScienceVisualAid,
> > > > FROM MasterList
> > > > WHERE (((MasterList.Teacher)=TName())) OR (((MasterList.GradeLevel)=TGrade()));
> > > >
> > > >
> > > >
> > > > ________________________________
> > > >  From: Duane Hookom <duanehookom@>
> > > > To: Access Professionals Yahoo Group <ms_access_professionals@yahoogroups.com>
> > > > Sent: Tuesday, July 31, 2012 12:07 PM
> > > > Subject: RE: [MS_AccessPros] A Query Problem
> > > > 
> > > >
> > > > Dan,
> > > > Feel free to share "some code that takes ..." and the SQL of "this Query to show the results".
> > > >
> > > > Most of us veterans build a WHERE CONDITION to use when opening forms and/or reports.
> > > >
> > > > Duane Hookom
> > > > MS Access MVP
> > > >
> > > > ----------------------------------------
> > > > > To: MS_Access_Professionals@yahoogroups.com
> > > > > From: amessyguy@
> > > > > Date: Tue, 31 Jul 2012 09:02:36 -0700
> > > > > Subject: [MS_AccessPros] A Query Problem
> > > > >
> > > > > I'm helping (a relative term) a friend with a problem passing more than one value to a Query.  We want to view student records either by Grade or by Teacher.
> > > > >
> > > > > I have some code that takes the selected grade from a ComboBox on a "selection Form" and passes it to the Query where the criteria for the GradeLevel field is Grade().  It works perfectly.
> > > > >
> > > > > I basically duplicated the Grade code, changing things where necessary, except this time for the teacher name.  It is on a separate "selection Form" that takes the teacher name entered into a TextBox and passes it along to the same Query where the criteria for the Teacher field is TName().
> > > > >
> > > > > There is a Form based on this Query to show the results.  It is supposed to open up having filtered records based on either of the selected criteria.  Everything works just fine--if I only have one criteria in my Query.  If I try to add the second criteria to the Query the results will only filter the last entry.  In other words, if on my first time through I select Smith for teacher I get the records for Smith's class.  I click a button that takes me back and this time I try Jones.  When I go to view the selected students I still see Smith's students.  If I click on the button that takes me back and this time select "7" for the grade level, I still see Smith's class.
> > > > >
> > > > > In order to get the TName() criteria to work I have to remove the Grade() criteria and vice versa.  Can you help me so I can get both of the criteria to play well together--in the same Query.
> > > > >
> > > > > Hope this makes sense.  As always--thanks!!!
> > > > >
> > > > > Dan
> > > > >
> > > > >
> > > > > [Non-text portions of this message have been removed]
> > > > >
> > > > >
> > > > >
> > > > > ------------------------------------
> > > > >
> > > > > Yahoo! Groups Links
> > > > >
> > > > >
> > > > >
> > > >                          
> > > >
> > > > ------------------------------------
> > > >
> > > > Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > > [Non-text portions of this message have been removed]
> > > >
> > >
> > >
> > >
> > >
> > > ------------------------------------
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
> [Non-text portions of this message have been removed]
>

------------------------------------

Yahoo! Groups Links

[Non-text portions of this message have been removed]

------------------------------------

Yahoo! Groups Links

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar