PC Review


Reply
Thread Tools Rate Thread

Access Runtime (Filter By Form)

 
 
=?Utf-8?B?cGF0ZW50aW52?=
Guest
Posts: n/a
 
      28th Dec 2005
I'm testing my Access 2003 DB in runtime mode, I'm recieving an error on a
macro that filters to a record on a form.
I''ve also tried converting it to to a VB Code Module, I still recieve an
error.

Here's the generated VB Module code it generated

Function Find_Applicant()
On Error GoTo Find_Applicant_Err

DoCmd.Echo False, "Please Stand By"
DoCmd.Hourglass True
DoCmd.RunCommand acCmdFilterByForm
DoCmd.RunCommand acCmdClearGrid


Find_Applicant_Exit:
Exit Function

Find_Applicant_Err:
MsgBox Error$
Resume Find_Applicant_Exit

End Function

Here are the error messages I receive,

It brings up a little box that says the (runcommand action was cancelled) I
click OK and it brings up another small box that says (OK) so i click Ok
and it brings up another little box that says (Resume with out error) I click
OK and it goes back to the same blank little box again, it does this forever
from (Resume with out error) to Blank Box with OK.


Thanks--Any help will be greatly appreciated.



 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      28th Dec 2005
Filter By Form is not available in the runtime.

You will need to code another way to let the user filter the form.

--
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.

"patentinv" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm testing my Access 2003 DB in runtime mode, I'm recieving an error on a
> macro that filters to a record on a form.
> I''ve also tried converting it to to a VB Code Module, I still recieve an
> error.
>
> Here's the generated VB Module code it generated
>
> Function Find_Applicant()
> On Error GoTo Find_Applicant_Err
>
> DoCmd.Echo False, "Please Stand By"
> DoCmd.Hourglass True
> DoCmd.RunCommand acCmdFilterByForm
> DoCmd.RunCommand acCmdClearGrid
>
>
> Find_Applicant_Exit:
> Exit Function
>
> Find_Applicant_Err:
> MsgBox Error$
> Resume Find_Applicant_Exit
>
> End Function
>
> Here are the error messages I receive,
>
> It brings up a little box that says the (runcommand action was cancelled)
> I
> click OK and it brings up another small box that says (OK) so i click Ok
> and it brings up another little box that says (Resume with out error) I
> click
> OK and it goes back to the same blank little box again, it does this
> forever
> from (Resume with out error) to Blank Box with OK.
>
>
> Thanks--Any help will be greatly appreciated.



 
Reply With Quote
 
 
 
 
=?Utf-8?B?cGF0ZW50aW52?=
Guest
Posts: n/a
 
      28th Dec 2005
Do you have any suggestions on how I can do this? or links to places for
similiar questions,
Thanks ,
"Allen Browne" wrote:

> Filter By Form is not available in the runtime.
>
> You will need to code another way to let the user filter the form.
>
> --
> 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.
>
> "patentinv" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I'm testing my Access 2003 DB in runtime mode, I'm recieving an error on a
> > macro that filters to a record on a form.
> > I''ve also tried converting it to to a VB Code Module, I still recieve an
> > error.
> >
> > Here's the generated VB Module code it generated
> >
> > Function Find_Applicant()
> > On Error GoTo Find_Applicant_Err
> >
> > DoCmd.Echo False, "Please Stand By"
> > DoCmd.Hourglass True
> > DoCmd.RunCommand acCmdFilterByForm
> > DoCmd.RunCommand acCmdClearGrid
> >
> >
> > Find_Applicant_Exit:
> > Exit Function
> >
> > Find_Applicant_Err:
> > MsgBox Error$
> > Resume Find_Applicant_Exit
> >
> > End Function
> >
> > Here are the error messages I receive,
> >
> > It brings up a little box that says the (runcommand action was cancelled)
> > I
> > click OK and it brings up another small box that says (OK) so i click Ok
> > and it brings up another little box that says (Resume with out error) I
> > click
> > OK and it goes back to the same blank little box again, it does this
> > forever
> > from (Resume with out error) to Blank Box with OK.
> >
> >
> > Thanks--Any help will be greatly appreciated.

>
>
>

 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      28th Dec 2005
In any form, there are usually only a few fields that the user is likely to
filter by. Some of these could be a range (such as a month or quarter.) What
I do is to place unbound controls of a different color in the Form Header
section, so the user can enter any combination of controls, and then click
the command button to filter them.

The button's Click event procedure builds a string from the non-null boxes,
and applies it to the Filter of the form. The filter string looks exactly
like the WHERE clause of a query, so you can mock up a query with any old
values and then switch it to SQL View (View menu) to see an example of what
you need to create.

The example below is structured so that it is very easy to add as many
filter controls as you need, tacking the AND onto the end of each one, and
removing the trailing AND at the end. It illustrates how to use the
delimiters for text and date fields, and to ensure the date is interpreted
correctly regardless of the user's regional settings.

Private Sub cmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
Const strcJetDate = "\#mm\/dd\/yyyy\#"

If Me.Dirty Then Me.Dirty = False 'Save first

If Not IsNull(Me.cboFilterCompanyID) Then 'Number field example.
strWhere = strWhere & "([CompanyID] = " & Me.cboFilterCompanyID & ")
AND "
End If

If Not IsNull(Me.txtFilterCity) Then 'Text field example
strWhere = strWhere "([City] = """ & Me.txtFilterCity & """) AND "
End If

If Not IsNull(Me.txtFilterInvoiceDate) Then 'Date field example
strWhere = strWhere & "([InvoiceDate] = " & _
Format(Me.txtFilterInvoiceDate, strcJetDate) & ") AND "
End If

lngLen = Len(strWhere) - 5 'without trailing " AND ".
If lngLen > 0 Then
Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True
Else
MsgBox "No criteria"
End If
End Sub


For an example of how to handle a date range, see Method 2 in this article:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html

If you want something more powerful than that, search for "Query by Form".

--
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.

"patentinv" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Do you have any suggestions on how I can do this? or links to places for
> similiar questions,
> Thanks ,
> "Allen Browne" wrote:
>
>> Filter By Form is not available in the runtime.
>>
>> You will need to code another way to let the user filter the form.
>>
>> "patentinv" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > I'm testing my Access 2003 DB in runtime mode, I'm recieving an error
>> > on a
>> > macro that filters to a record on a form.
>> > I''ve also tried converting it to to a VB Code Module, I still recieve
>> > an
>> > error.
>> >
>> > Here's the generated VB Module code it generated
>> >
>> > Function Find_Applicant()
>> > On Error GoTo Find_Applicant_Err
>> >
>> > DoCmd.Echo False, "Please Stand By"
>> > DoCmd.Hourglass True
>> > DoCmd.RunCommand acCmdFilterByForm
>> > DoCmd.RunCommand acCmdClearGrid
>> >
>> >
>> > Find_Applicant_Exit:
>> > Exit Function
>> >
>> > Find_Applicant_Err:
>> > MsgBox Error$
>> > Resume Find_Applicant_Exit
>> >
>> > End Function
>> >
>> > Here are the error messages I receive,
>> >
>> > It brings up a little box that says the (runcommand action was
>> > cancelled)
>> > I
>> > click OK and it brings up another small box that says (OK) so i click
>> > Ok
>> > and it brings up another little box that says (Resume with out error) I
>> > click
>> > OK and it goes back to the same blank little box again, it does this
>> > forever
>> > from (Resume with out error) to Blank Box with OK.
>> >
>> >
>> > Thanks--Any help will be greatly appreciated.



 
Reply With Quote
 
=?Utf-8?B?cGF0ZW50aW52?=
Guest
Posts: n/a
 
      28th Dec 2005
Let's say I had the filter set on customer name and address like you stated.
And the user selected customer as there filtering option and entered there
customer name and clicked the command button filter will the filter bring
back the whole record set customer address, ph #'s, email address and all
data in that record set in all of the tables the data resides in?

Thanks--Allen
"Allen Browne" wrote:

> In any form, there are usually only a few fields that the user is likely to
> filter by. Some of these could be a range (such as a month or quarter.) What
> I do is to place unbound controls of a different color in the Form Header
> section, so the user can enter any combination of controls, and then click
> the command button to filter them.
>
> The button's Click event procedure builds a string from the non-null boxes,
> and applies it to the Filter of the form. The filter string looks exactly
> like the WHERE clause of a query, so you can mock up a query with any old
> values and then switch it to SQL View (View menu) to see an example of what
> you need to create.
>
> The example below is structured so that it is very easy to add as many
> filter controls as you need, tacking the AND onto the end of each one, and
> removing the trailing AND at the end. It illustrates how to use the
> delimiters for text and date fields, and to ensure the date is interpreted
> correctly regardless of the user's regional settings.
>
> Private Sub cmdFilter_Click()
> Dim strWhere As String
> Dim lngLen As Long
> Const strcJetDate = "\#mm\/dd\/yyyy\#"
>
> If Me.Dirty Then Me.Dirty = False 'Save first
>
> If Not IsNull(Me.cboFilterCompanyID) Then 'Number field example.
> strWhere = strWhere & "([CompanyID] = " & Me.cboFilterCompanyID & ")
> AND "
> End If
>
> If Not IsNull(Me.txtFilterCity) Then 'Text field example
> strWhere = strWhere "([City] = """ & Me.txtFilterCity & """) AND "
> End If
>
> If Not IsNull(Me.txtFilterInvoiceDate) Then 'Date field example
> strWhere = strWhere & "([InvoiceDate] = " & _
> Format(Me.txtFilterInvoiceDate, strcJetDate) & ") AND "
> End If
>
> lngLen = Len(strWhere) - 5 'without trailing " AND ".
> If lngLen > 0 Then
> Me.Filter = Left(strWhere, lngLen)
> Me.FilterOn = True
> Else
> MsgBox "No criteria"
> End If
> End Sub
>
>
> For an example of how to handle a date range, see Method 2 in this article:
> Limiting a Report to a Date Range
> at:
> http://allenbrowne.com/casu-08.html
>
> If you want something more powerful than that, search for "Query by Form".
>
> --
> 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.
>
> "patentinv" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Do you have any suggestions on how I can do this? or links to places for
> > similiar questions,
> > Thanks ,
> > "Allen Browne" wrote:
> >
> >> Filter By Form is not available in the runtime.
> >>
> >> You will need to code another way to let the user filter the form.
> >>
> >> "patentinv" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > I'm testing my Access 2003 DB in runtime mode, I'm recieving an error
> >> > on a
> >> > macro that filters to a record on a form.
> >> > I''ve also tried converting it to to a VB Code Module, I still recieve
> >> > an
> >> > error.
> >> >
> >> > Here's the generated VB Module code it generated
> >> >
> >> > Function Find_Applicant()
> >> > On Error GoTo Find_Applicant_Err
> >> >
> >> > DoCmd.Echo False, "Please Stand By"
> >> > DoCmd.Hourglass True
> >> > DoCmd.RunCommand acCmdFilterByForm
> >> > DoCmd.RunCommand acCmdClearGrid
> >> >
> >> >
> >> > Find_Applicant_Exit:
> >> > Exit Function
> >> >
> >> > Find_Applicant_Err:
> >> > MsgBox Error$
> >> > Resume Find_Applicant_Exit
> >> >
> >> > End Function
> >> >
> >> > Here are the error messages I receive,
> >> >
> >> > It brings up a little box that says the (runcommand action was
> >> > cancelled)
> >> > I
> >> > click OK and it brings up another small box that says (OK) so i click
> >> > Ok
> >> > and it brings up another little box that says (Resume with out error) I
> >> > click
> >> > OK and it goes back to the same blank little box again, it does this
> >> > forever
> >> > from (Resume with out error) to Blank Box with OK.
> >> >
> >> >
> >> > Thanks--Any help will be greatly appreciated.

>
>
>

 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      28th Dec 2005
The filter is just the criteria. It does not affect which fields are
returned.

--
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.

"patentinv" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Let's say I had the filter set on customer name and address like you
> stated.
> And the user selected customer as there filtering option and entered there
> customer name and clicked the command button filter will the filter bring
> back the whole record set customer address, ph #'s, email address and all
> data in that record set in all of the tables the data resides in?



 
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
Set Form height at Runtime Access 2007 Runtime Sue L. Microsoft Access Form Coding 4 12th Jan 2010 04:17 PM
Microsoft Visual C++ Runtime Library Runtime Error John Hall Windows XP Help 0 28th Sep 2004 03:20 AM
Visual c++ runtime Library runtime error. - c runtime error.jpg (0/1) ... Windows XP Accessibility 0 1st May 2004 06:26 PM
RE: ms visual c++ runtime library runtime error =?Utf-8?B?Qnl0ZQ==?= Windows XP Help 1 11th Mar 2004 11:52 PM
Re: ms visual c++ runtime library runtime error Michael Solomon \(MS-MVP Windows Shell/User\) Windows XP Help 0 11th Mar 2004 10:50 PM


Features
 

Advertising
 

Newsgroups
 


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