PC Review


Reply
Thread Tools Rate Thread

"WHERE" clauses in DoCmd.OpenForm no longer working

 
 
Chris O''Neill
Guest
Posts: n/a
 
      26th Aug 2008
I'm not sure what I've done, but I've messed something up big time.

I have a number of subs (mostly command buttons) where I open another form
filtering on a control in the current form. My syntax is like this:

strCriteria = "[GLID] = " & Me.txtGLPostingID
DoCmd.OpenForm "frmGeneralLedger", , , strCriteria

In the above case, GLID and Me.txtGLPostingID are both numbers. When the
fields/controls I'm working with are strings, I use this syntax:

strCriteria = "[Company] = " & Chr(34) & Me.txtCompany & Chr(34)
DoCmd.OpenForm "frmCompanyInfo",,, strCriteria

All of this worked up until today. Today, none of these "WHERE" clauses
work. So, I'm sure it's not a syntax problem with one subroutine but,
rather, something I've done application-wide. When I print out any of the
strCriteria lines in the Immediate Window, everything appears as it should
but they still don't work.

Thoughts, suggestions, hints/tips on what I might have messed up to cause
this problem? Any help offered is greatly appreciated!

Regards, Chris

 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      26th Aug 2008
Chis, when everything goes haywire, it might be time to backup, compact,
decompile, and then compact twice again. Detailed steps:
http://allenbrowne.com/recover.html

Are you certain the other forms are not open already? Not even in design
view? The OpenForm won't apply the filter if they are.

You may also want to check under tools | Options in the VBA window, to make
sure you have your error handling set to Break on Unhandled Errors (and
Compile on Demand turned off), so you get notified of any error.

Beyond that, I take it that the form is opening, so see if the filter is
applied after you open it:
? Forms!frmGeneralLedger.Filter
? Forms!frmGeneralLedger.FilterOn
Access doesn't always report FilterOn correctly for reports, but it does for
forms.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Chris O''Neill" <(E-Mail Removed)> wrote in message
news:EB61B847-9D86-4C3D-945B-(E-Mail Removed)...
> I'm not sure what I've done, but I've messed something up big time.
>
> I have a number of subs (mostly command buttons) where I open another form
> filtering on a control in the current form. My syntax is like this:
>
> strCriteria = "[GLID] = " & Me.txtGLPostingID
> DoCmd.OpenForm "frmGeneralLedger", , , strCriteria
>
> In the above case, GLID and Me.txtGLPostingID are both numbers. When the
> fields/controls I'm working with are strings, I use this syntax:
>
> strCriteria = "[Company] = " & Chr(34) & Me.txtCompany & Chr(34)
> DoCmd.OpenForm "frmCompanyInfo",,, strCriteria
>
> All of this worked up until today. Today, none of these "WHERE" clauses
> work. So, I'm sure it's not a syntax problem with one subroutine but,
> rather, something I've done application-wide. When I print out any of the
> strCriteria lines in the Immediate Window, everything appears as it should
> but they still don't work.
>
> Thoughts, suggestions, hints/tips on what I might have messed up to cause
> this problem? Any help offered is greatly appreciated!
>
> Regards, Chris
>


 
Reply With Quote
 
Chris O''Neill
Guest
Posts: n/a
 
      26th Aug 2008
Thank you, Allen, for those suggestions. That's exactly the kind of info I
was looking for. I'll take a look at it in awhile... my wife insisted that
I make my famous ginger snap cookies for dessert tonight.

Btw, the forms all load but none of them are filtering. I opened them in
design mode and the Properties window shows the correct filter strings and
filtering on. I haven't checked in the Immediate Window to see what the
..Filter and .FilterOn properties are, but I'll do that after the cookies are
done.

Thanks, again, for your help. My bet is I'll find it's some *really*
stoooooopid mistake on my part. (sheepish grin!)

Regards, Chris

"Allen Browne" wrote:

> Chis, when everything goes haywire, it might be time to backup, compact,
> decompile, and then compact twice again. Detailed steps:
> http://allenbrowne.com/recover.html
>
> Are you certain the other forms are not open already? Not even in design
> view? The OpenForm won't apply the filter if they are.
>
> You may also want to check under tools | Options in the VBA window, to make
> sure you have your error handling set to Break on Unhandled Errors (and
> Compile on Demand turned off), so you get notified of any error.
>
> Beyond that, I take it that the form is opening, so see if the filter is
> applied after you open it:
> ? Forms!frmGeneralLedger.Filter
> ? Forms!frmGeneralLedger.FilterOn
> Access doesn't always report FilterOn correctly for reports, but it does for
> forms.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Chris O''Neill" <(E-Mail Removed)> wrote in message
> news:EB61B847-9D86-4C3D-945B-(E-Mail Removed)...
> > I'm not sure what I've done, but I've messed something up big time.
> >
> > I have a number of subs (mostly command buttons) where I open another form
> > filtering on a control in the current form. My syntax is like this:
> >
> > strCriteria = "[GLID] = " & Me.txtGLPostingID
> > DoCmd.OpenForm "frmGeneralLedger", , , strCriteria
> >
> > In the above case, GLID and Me.txtGLPostingID are both numbers. When the
> > fields/controls I'm working with are strings, I use this syntax:
> >
> > strCriteria = "[Company] = " & Chr(34) & Me.txtCompany & Chr(34)
> > DoCmd.OpenForm "frmCompanyInfo",,, strCriteria
> >
> > All of this worked up until today. Today, none of these "WHERE" clauses
> > work. So, I'm sure it's not a syntax problem with one subroutine but,
> > rather, something I've done application-wide. When I print out any of the
> > strCriteria lines in the Immediate Window, everything appears as it should
> > but they still don't work.
> >
> > Thoughts, suggestions, hints/tips on what I might have messed up to cause
> > this problem? Any help offered is greatly appreciated!
> >
> > Regards, Chris
> >

>
>

 
Reply With Quote
 
Chris O''Neill
Guest
Posts: n/a
 
      26th Aug 2008
I found the problem and, yup, it's a *reallly* stoooopid oversight on my part.

Awhile back, I added some filtering functions to the OnOpen event of several
forms. It just happens that some of these are the same forms I'm now trying
to open with the "WHERE" clause of the DoCmd.OpenForm command. So, of
course, what's happening is that the DoCmd opens the form with the desired
filter, and then the OnLoad event immediately changes it to another filter
string! (DOH!!!!)

[He hangs his head in shame....]

I guess I'm going to have to use openargs to pass my new filter string and
then, using an IF/THEN/ELSE append that to the string in the OnLoad event
before I apply the filter. (The reason I'm going to do it this way is
because in most cases I want to open the forms with the filter coded in the
OnLoad event, but occassionally in specific circumstances I want to open it
with the other filter.) Does that make sense, everyone???

Anyway, Allen, I again thank you for pointing me in the right direction. I
probably would've muddled around for days until I figured that out on my own.
Btw, I'm now going to follow that advice in the link you gave me.... time
to backup, compact, etc. just to be sure everything's in order.

Thanks, again...

Regards, Chris

"Allen Browne" wrote:

> Chis, when everything goes haywire, it might be time to backup, compact,
> decompile, and then compact twice again. Detailed steps:
> http://allenbrowne.com/recover.html
>
> Are you certain the other forms are not open already? Not even in design
> view? The OpenForm won't apply the filter if they are.
>
> You may also want to check under tools | Options in the VBA window, to make
> sure you have your error handling set to Break on Unhandled Errors (and
> Compile on Demand turned off), so you get notified of any error.
>
> Beyond that, I take it that the form is opening, so see if the filter is
> applied after you open it:
> ? Forms!frmGeneralLedger.Filter
> ? Forms!frmGeneralLedger.FilterOn
> Access doesn't always report FilterOn correctly for reports, but it does for
> forms.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Chris O''Neill" <(E-Mail Removed)> wrote in message
> news:EB61B847-9D86-4C3D-945B-(E-Mail Removed)...
> > I'm not sure what I've done, but I've messed something up big time.
> >
> > I have a number of subs (mostly command buttons) where I open another form
> > filtering on a control in the current form. My syntax is like this:
> >
> > strCriteria = "[GLID] = " & Me.txtGLPostingID
> > DoCmd.OpenForm "frmGeneralLedger", , , strCriteria
> >
> > In the above case, GLID and Me.txtGLPostingID are both numbers. When the
> > fields/controls I'm working with are strings, I use this syntax:
> >
> > strCriteria = "[Company] = " & Chr(34) & Me.txtCompany & Chr(34)
> > DoCmd.OpenForm "frmCompanyInfo",,, strCriteria
> >
> > All of this worked up until today. Today, none of these "WHERE" clauses
> > work. So, I'm sure it's not a syntax problem with one subroutine but,
> > rather, something I've done application-wide. When I print out any of the
> > strCriteria lines in the Immediate Window, everything appears as it should
> > but they still don't work.
> >
> > Thoughts, suggestions, hints/tips on what I might have messed up to cause
> > this problem? Any help offered is greatly appreciated!
> >
> > Regards, Chris
> >

>
>

 
Reply With Quote
 
Tony Toews [MVP]
Guest
Posts: n/a
 
      26th Aug 2008
Chris O''Neill <(E-Mail Removed)> wrote:

>I guess I'm going to have to use openargs to pass my new filter string and
>then, using an IF/THEN/ELSE append that to the string in the OnLoad event
>before I apply the filter. (The reason I'm going to do it this way is
>because in most cases I want to open the forms with the filter coded in the
>OnLoad event, but occassionally in specific circumstances I want to open it
>with the other filter.) Does that make sense, everyone???


Yup, makes sense. I do that kind of thing all the time. For example
I might have a continuous form which you can view and search on from
the main menu. However sometimes I might want to call that from
another form limiting the search criteria by customer or unit or some
such.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I am not "getting" it.....DoCmd. OpenForm Peter Microsoft Access Form Coding 4 12th Oct 2009 01:20 PM
Cannot open a form using "Docmd Openform" PAC Microsoft Access Forms 1 2nd Aug 2009 05:19 PM
If checkbox = True Then DoCmd.OpenForm "NOT WORKING" JNariss@gmail.com Microsoft Access Form Coding 4 17th Feb 2006 02:30 PM
Re-Post - DoCmd.OpenForm Modality Problem - Form's Modal = "Yes" =?Utf-8?B?R2FyeVo=?= Microsoft Access Macros 3 29th Nov 2004 02:23 PM
"docmd.OpenForm stDocName, , , stLinkCriteria" =?Utf-8?B?R3JheQ==?= Microsoft Access 1 5th Sep 2004 10:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:25 AM.