Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Remove filter

Geek News

Remove filter
"CJ" <private[ at ]newsgroups.com> 11/25/2008 3:09:39 AM
Hi Groupies

I use the following code on a command button to open a form
to a newly created record based on data input into a form.

stDocName = "frmWorkOrder"
stLinkCriteria = "[lngWOId]=" & Me![lngWOId]

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm stDocName, , , stLinkCriteria

My question is how do I open the form frmWorkOrder to the new record
but remove the form filter so that I can move to other records?

I have tried using DoCmd.OpenForm stDocName, , acEntire,
stLinkCriteria
but that just gives me an error message.

--
Thanks for taking the time!

CJ
---------------------------------------------------------
Know thyself, know thy limits....know thy newsgroups!

Re: Remove filter
"RipperT" <<RiPpErT>[ at ]nOsPaM.nEt> 11/25/2008 4:01:25 AM
You can't. You would have to open the form to all records first, then use
the FindFirst method to hunt down the record you just saved based on some
criteria. Too much work. I would simply put a button on the form called Show
All with Docmd.ShowAllRecords behind it. That way the form will open to your
new record as instructed, but when you're done with it, just hit the new
Show All button. There's also a toobar button that removes the filter.

Rip


"CJ" <private[ at ]newsgroups.com> wrote in message
news:OTISEtqTJHA.1908[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text]
> Hi Groupies
>
> I use the following code on a command button to open a form
> to a newly created record based on data input into a form.
>
> stDocName = "frmWorkOrder"
> stLinkCriteria = "[lngWOId]=" & Me![lngWOId]
>
> DoCmd.RunCommand acCmdSaveRecord
> DoCmd.OpenForm stDocName, , , stLinkCriteria
>
> My question is how do I open the form frmWorkOrder to the new record
> but remove the form filter so that I can move to other records?
>
> I have tried using DoCmd.OpenForm stDocName, , acEntire,
> stLinkCriteria
> but that just gives me an error message.
>
> --
> Thanks for taking the time!
>
> CJ
> ---------------------------------------------------------
> Know thyself, know thy limits....know thy newsgroups!


Re: Remove filter
"Dirk Goldgar" <dg[ at ]NOdataSPAMgnostics.com.invalid> 11/25/2008 4:12:07 AM
"CJ" <private[ at ]newsgroups.com> wrote in message
news:OTISEtqTJHA.1908[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text]
> Hi Groupies
>
> I use the following code on a command button to open a form
> to a newly created record based on data input into a form.
>
> stDocName = "frmWorkOrder"
> stLinkCriteria = "[lngWOId]=" & Me![lngWOId]
>
> DoCmd.RunCommand acCmdSaveRecord
> DoCmd.OpenForm stDocName, , , stLinkCriteria
>
> My question is how do I open the form frmWorkOrder to the new record
> but remove the form filter so that I can move to other records?
>
> I have tried using DoCmd.OpenForm stDocName, , acEntire,
> stLinkCriteria
> but that just gives me an error message.


So lngWOId identifies the record you just created and saved? You can open
the form and position it to that record like this:

DoCmd.OpenForm strDocName
Forms(strDocName).Recordset.FindFirst stLinkCriteria


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Re: Remove filter
"CJ" <private[ at ]newsgroups.com> 11/25/2008 8:42:59 PM
Hi Dirk, thanks for popping in.

Your code worked perfectly, thanks very much!

--
Thanks for taking the time!

CJ
---------------------------------------------------------
Know thyself, know thy limits....know thy newsgroups!
"Dirk Goldgar" <dg[ at ]NOdataSPAMgnostics.com.invalid> wrote in message
news:OyZD%23PrTJHA.584[ at ]TK2MSFTNGP06.phx.gbl...
[Quoted Text]
> "CJ" <private[ at ]newsgroups.com> wrote in message
> news:OTISEtqTJHA.1908[ at ]TK2MSFTNGP04.phx.gbl...
>> Hi Groupies
>>
>> I use the following code on a command button to open a form
>> to a newly created record based on data input into a form.
>>
>> stDocName = "frmWorkOrder"
>> stLinkCriteria = "[lngWOId]=" & Me![lngWOId]
>>
>> DoCmd.RunCommand acCmdSaveRecord
>> DoCmd.OpenForm stDocName, , , stLinkCriteria
>>
>> My question is how do I open the form frmWorkOrder to the new record
>> but remove the form filter so that I can move to other records?
>>
>> I have tried using DoCmd.OpenForm stDocName, , acEntire,
>> stLinkCriteria
>> but that just gives me an error message.
>
>
> So lngWOId identifies the record you just created and saved? You can open
> the form and position it to that record like this:
>
> DoCmd.OpenForm strDocName
> Forms(strDocName).Recordset.FindFirst stLinkCriteria
>
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>

Re: Remove filter
"CJ" <private[ at ]newsgroups.com> 11/25/2008 8:44:26 PM
Hi Ripper

FYI Dirk had a solution that was super simple.

DoCmd.OpenForm strDocName
Forms(strDocName).Recordset.FindFirst stLinkCriteria

--
Thanks for taking the time!

CJ
---------------------------------------------------------
Know thyself, know thy limits....know thy newsgroups!
"RipperT [ at ]nOsPaM.nEt>" <<RiPpErT> wrote in message
news:Ohe%231JrTJHA.5080[ at ]TK2MSFTNGP03.phx.gbl...
[Quoted Text]
> You can't. You would have to open the form to all records first, then use
> the FindFirst method to hunt down the record you just saved based on some
> criteria. Too much work. I would simply put a button on the form called
> Show All with Docmd.ShowAllRecords behind it. That way the form will open
> to your new record as instructed, but when you're done with it, just hit
> the new Show All button. There's also a toobar button that removes the
> filter.
>
> Rip
>
>
> "CJ" <private[ at ]newsgroups.com> wrote in message
> news:OTISEtqTJHA.1908[ at ]TK2MSFTNGP04.phx.gbl...
>> Hi Groupies
>>
>> I use the following code on a command button to open a form
>> to a newly created record based on data input into a form.
>>
>> stDocName = "frmWorkOrder"
>> stLinkCriteria = "[lngWOId]=" & Me![lngWOId]
>>
>> DoCmd.RunCommand acCmdSaveRecord
>> DoCmd.OpenForm stDocName, , , stLinkCriteria
>>
>> My question is how do I open the form frmWorkOrder to the new record
>> but remove the form filter so that I can move to other records?
>>
>> I have tried using DoCmd.OpenForm stDocName, , acEntire,
>> stLinkCriteria
>> but that just gives me an error message.
>>
>> --
>> Thanks for taking the time!
>>
>> CJ
>> ---------------------------------------------------------
>> Know thyself, know thy limits....know thy newsgroups!
>
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net