Remove filter

C

CJ

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

RipperT

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
 
D

Dirk Goldgar

CJ said:
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
 
C

CJ

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 said:
CJ said:
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)
 
C

CJ

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 @nOsPaM.nEt> said:
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 said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top